Compare commits
No commits in common. "main" and "v5.7.0" have entirely different histories.
34
Makefile
34
Makefile
|
|
@ -1,8 +1,6 @@
|
|||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Top level Makefile for iproute2
|
||||
|
||||
-include config.mk
|
||||
|
||||
ifeq ("$(origin V)", "command line")
|
||||
VERBOSE = $(V)
|
||||
endif
|
||||
|
|
@ -15,6 +13,7 @@ MAKEFLAGS += --no-print-directory
|
|||
endif
|
||||
|
||||
PREFIX?=/usr
|
||||
LIBDIR?=$(PREFIX)/lib
|
||||
SBINDIR?=/sbin
|
||||
CONFDIR?=/etc/iproute2
|
||||
NETNS_RUN_DIR?=/var/run/netns
|
||||
|
|
@ -41,18 +40,9 @@ DEFINES+=-DCONFDIR=\"$(CONFDIR)\" \
|
|||
-DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \
|
||||
-DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\"
|
||||
|
||||
#options for AX.25
|
||||
ADDLIB+=ax25_ntop.o
|
||||
|
||||
#options for AX.25
|
||||
ADDLIB+=rose_ntop.o
|
||||
|
||||
#options for mpls
|
||||
ADDLIB+=mpls_ntop.o mpls_pton.o
|
||||
|
||||
#options for NETROM
|
||||
ADDLIB+=netrom_ntop.o
|
||||
|
||||
CC := gcc
|
||||
HOSTCC ?= $(CC)
|
||||
DEFINES += -D_GNU_SOURCE
|
||||
|
|
@ -65,7 +55,7 @@ WFLAGS += -Wmissing-declarations -Wold-style-definition -Wformat=2
|
|||
CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
|
||||
YACCFLAGS = -d -t -v
|
||||
|
||||
SUBDIRS=lib ip tc bridge misc netem genl tipc devlink rdma dcb man vdpa
|
||||
SUBDIRS=lib ip tc bridge misc netem genl tipc devlink rdma man
|
||||
|
||||
LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a
|
||||
LDLIBS += $(LIBNETLINK)
|
||||
|
|
@ -73,9 +63,7 @@ LDLIBS += $(LIBNETLINK)
|
|||
all: config.mk
|
||||
@set -e; \
|
||||
for i in $(SUBDIRS); \
|
||||
do echo; echo $$i; $(MAKE) -C $$i; done
|
||||
|
||||
.PHONY: clean clobber distclean check cscope version
|
||||
do echo; echo $$i; $(MAKE) $(MFLAGS) -C $$i; done
|
||||
|
||||
help:
|
||||
@echo "Make Targets:"
|
||||
|
|
@ -85,15 +73,13 @@ help:
|
|||
@echo " install - install binaries on local machine"
|
||||
@echo " check - run tests"
|
||||
@echo " cscope - build cscope database"
|
||||
@echo " version - update version"
|
||||
@echo " snapshot - generate version number header"
|
||||
@echo ""
|
||||
@echo "Make Arguments:"
|
||||
@echo " V=[0|1] - set build verbosity level"
|
||||
|
||||
config.mk:
|
||||
@if [ ! -f config.mk -o configure -nt config.mk ]; then \
|
||||
sh configure $(KERNEL_INCLUDE); \
|
||||
fi
|
||||
sh configure $(KERNEL_INCLUDE)
|
||||
|
||||
install: all
|
||||
install -m 0755 -d $(DESTDIR)$(SBINDIR)
|
||||
|
|
@ -107,17 +93,17 @@ install: all
|
|||
install -m 0644 bash-completion/devlink $(DESTDIR)$(BASH_COMPDIR)
|
||||
install -m 0644 include/bpf_elf.h $(DESTDIR)$(HDRDIR)
|
||||
|
||||
version:
|
||||
echo "static const char version[] = \""`git describe --tags --long`"\";" \
|
||||
> include/version.h
|
||||
snapshot:
|
||||
echo "static const char SNAPSHOT[] = \""`date +%y%m%d`"\";" \
|
||||
> include/SNAPSHOT.h
|
||||
|
||||
clean:
|
||||
@for i in $(SUBDIRS) testsuite; \
|
||||
do $(MAKE) -C $$i clean; done
|
||||
do $(MAKE) $(MFLAGS) -C $$i clean; done
|
||||
|
||||
clobber:
|
||||
touch config.mk
|
||||
$(MAKE) clean
|
||||
$(MAKE) $(MFLAGS) clean
|
||||
rm -f config.mk cscope.*
|
||||
|
||||
distclean: clobber
|
||||
|
|
|
|||
15
README
15
README
|
|
@ -28,12 +28,17 @@ The makefile will automatically build a config.mk file which
|
|||
contains definitions of libraries that may or may not be available
|
||||
on the system such as: ATM, ELF, MNL, and SELINUX.
|
||||
|
||||
3. include/uapi
|
||||
3. To make documentation, cd to doc/ directory , then
|
||||
look at start of Makefile and set correct values for
|
||||
PAGESIZE=a4 , ie: a4 , letter ... (string)
|
||||
PAGESPERPAGE=2 , ie: 1 , 2 ... (numeric)
|
||||
and make there. It assumes, that latex, dvips and psnup
|
||||
are in your path.
|
||||
|
||||
This package includes matching sanitized kernel headers because
|
||||
the build environment may not have up to date versions. See Makefile
|
||||
if you have special requirements and need to point at different
|
||||
kernel include files.
|
||||
4. This package includes matching sanitized kernel headers because
|
||||
the build environment may not have up to date versions. See Makefile
|
||||
if you have special requirements and need to point at different
|
||||
kernel include files.
|
||||
|
||||
Stephen Hemminger
|
||||
stephen@networkplumber.org
|
||||
|
|
|
|||
|
|
@ -319,57 +319,6 @@ _devlink_port_split()
|
|||
esac
|
||||
}
|
||||
|
||||
# Completion for devlink port param set
|
||||
_devlink_port_param_set()
|
||||
{
|
||||
case $cword in
|
||||
7)
|
||||
COMPREPLY=( $( compgen -W "value" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
8)
|
||||
# String argument
|
||||
return
|
||||
;;
|
||||
9)
|
||||
COMPREPLY=( $( compgen -W "cmode" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
10)
|
||||
COMPREPLY=( $( compgen -W "runtime driverinit permanent" -- \
|
||||
"$cur" ) )
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Completion for devlink port param
|
||||
_devlink_port_param()
|
||||
{
|
||||
case "$cword" in
|
||||
3)
|
||||
COMPREPLY=( $( compgen -W "show set" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
4)
|
||||
_devlink_direct_complete "port"
|
||||
return
|
||||
;;
|
||||
5)
|
||||
COMPREPLY=( $( compgen -W "name" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
6)
|
||||
_devlink_direct_complete "param_name"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "${words[3]}" == "set" ]]; then
|
||||
_devlink_port_param_set
|
||||
fi
|
||||
}
|
||||
|
||||
# Completion for devlink port
|
||||
_devlink_port()
|
||||
{
|
||||
|
|
@ -382,10 +331,6 @@ _devlink_port()
|
|||
_devlink_port_split
|
||||
return
|
||||
;;
|
||||
param)
|
||||
_devlink_port_param
|
||||
return
|
||||
;;
|
||||
show|unsplit)
|
||||
if [[ $cword -eq 3 ]]; then
|
||||
_devlink_direct_complete "port"
|
||||
|
|
@ -690,7 +635,7 @@ _devlink_health_reporter()
|
|||
_devlink_health()
|
||||
{
|
||||
case $command in
|
||||
show|recover|diagnose|set|test)
|
||||
show|recover|diagnose|set)
|
||||
_devlink_health_reporter 0
|
||||
if [[ $command == "set" ]]; then
|
||||
case $cword in
|
||||
|
|
@ -733,7 +678,7 @@ _devlink_trap_set_action()
|
|||
COMPREPLY=( $( compgen -W "action" -- "$cur" ) )
|
||||
;;
|
||||
$((7 + $i)))
|
||||
COMPREPLY=( $( compgen -W "trap drop mirror" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "trap drop" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -763,7 +708,7 @@ _devlink_trap_group_set()
|
|||
|
||||
case $prev in
|
||||
action)
|
||||
COMPREPLY=( $( compgen -W "trap drop mirror" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "trap drop" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
policer)
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@ void print_vlan_info(struct rtattr *tb, int ifindex);
|
|||
int print_linkinfo(struct nlmsghdr *n, void *arg);
|
||||
int print_mdb_mon(struct nlmsghdr *n, void *arg);
|
||||
int print_fdb(struct nlmsghdr *n, void *arg);
|
||||
void print_stp_state(__u8 state);
|
||||
int parse_stp_state(const char *arg);
|
||||
int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor,
|
||||
bool global_only);
|
||||
void br_print_router_port_stats(struct rtattr *pattr);
|
||||
|
||||
int do_fdb(int argc, char **argv);
|
||||
int do_mdb(int argc, char **argv);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "SNAPSHOT.h"
|
||||
#include "utils.h"
|
||||
#include "br_common.h"
|
||||
#include "namespace.h"
|
||||
|
|
@ -37,10 +37,10 @@ static void usage(void)
|
|||
fprintf(stderr,
|
||||
"Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||
" bridge [ -force ] -batch filename\n"
|
||||
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
|
||||
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
|
||||
" -o[neline] | -t[imestamp] | -n[etns] name |\n"
|
||||
" -c[ompressvlans] -color -p[retty] -j[son] }\n");
|
||||
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
|
||||
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
|
||||
" -o[neline] | -t[imestamp] | -n[etns] name |\n"
|
||||
" -c[ompressvlans] -color -p[retty] -j[son] }\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
@ -77,14 +77,20 @@ static int do_cmd(const char *argv0, int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int br_batch_cmd(int argc, char *argv[], void *data)
|
||||
{
|
||||
return do_cmd(argv[0], argc, argv);
|
||||
}
|
||||
|
||||
static int batch(const char *name)
|
||||
{
|
||||
int ret;
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
if (name && strcmp(name, "-") != 0) {
|
||||
if (freopen(name, "r", stdin) == NULL) {
|
||||
fprintf(stderr,
|
||||
"Cannot open file \"%s\" for reading: %s\n",
|
||||
name, strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (rtnl_open(&rth, 0) < 0) {
|
||||
fprintf(stderr, "Cannot open rtnetlink\n");
|
||||
|
|
@ -93,7 +99,25 @@ static int batch(const char *name)
|
|||
|
||||
rtnl_set_strict_dump(&rth);
|
||||
|
||||
ret = do_batch(name, force, br_batch_cmd, NULL);
|
||||
cmdlineno = 0;
|
||||
while (getcmdline(&line, &len, stdin) != -1) {
|
||||
char *largv[100];
|
||||
int largc;
|
||||
|
||||
largc = makeargs(line, largv, 100);
|
||||
if (largc == 0)
|
||||
continue; /* blank line */
|
||||
|
||||
if (do_cmd(largv[0], largc, largv)) {
|
||||
fprintf(stderr, "Command failed %s:%d\n",
|
||||
name, cmdlineno);
|
||||
ret = EXIT_FAILURE;
|
||||
if (!force)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (line)
|
||||
free(line);
|
||||
|
||||
rtnl_close(&rth);
|
||||
return ret;
|
||||
|
|
@ -117,7 +141,7 @@ main(int argc, char **argv)
|
|||
if (matches(opt, "-help") == 0) {
|
||||
usage();
|
||||
} else if (matches(opt, "-Version") == 0) {
|
||||
printf("bridge utility, %s\n", version);
|
||||
printf("bridge utility, 0.0\n");
|
||||
exit(0);
|
||||
} else if (matches(opt, "-stats") == 0 ||
|
||||
matches(opt, "-statistics") == 0) {
|
||||
|
|
@ -149,9 +173,9 @@ main(int argc, char **argv)
|
|||
NEXT_ARG();
|
||||
if (netns_switch(argv[1]))
|
||||
exit(-1);
|
||||
} else if (matches_color(opt, &color)) {
|
||||
} else if (matches(opt, "-compressvlans") == 0) {
|
||||
++compress_vlans;
|
||||
} else if (matches_color(opt, &color)) {
|
||||
} else if (matches(opt, "-force") == 0) {
|
||||
++force;
|
||||
} else if (matches(opt, "-json") == 0) {
|
||||
|
|
|
|||
61
bridge/fdb.c
61
bridge/fdb.c
|
|
@ -30,21 +30,19 @@
|
|||
#include "rt_names.h"
|
||||
#include "utils.h"
|
||||
|
||||
static unsigned int filter_index, filter_dynamic, filter_master,
|
||||
filter_state, filter_vlan;
|
||||
static unsigned int filter_index, filter_vlan, filter_state, filter_master;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: bridge fdb { add | append | del | replace } ADDR dev DEV\n"
|
||||
" [ self ] [ master ] [ use ] [ router ] [ extern_learn ]\n"
|
||||
" [ sticky ] [ local | static | dynamic ] [ vlan VID ]\n"
|
||||
" { [ dst IPADDR ] [ port PORT] [ vni VNI ] | [ nhid NHID ] }\n"
|
||||
" [ via DEV ] [ src_vni VNI ]\n"
|
||||
" bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ]\n"
|
||||
" [ state STATE ] [ dynamic ] ]\n"
|
||||
" bridge fdb get [ to ] LLADDR [ br BRDEV ] { brport | dev } DEV\n"
|
||||
" [ vlan VID ] [ vni VNI ] [ self ] [ master ] [ dynamic ]\n");
|
||||
" [ sticky ] [ local | static | dynamic ] [ dst IPADDR ]\n"
|
||||
" [ vlan VID ] [ port PORT] [ vni VNI ] [ via DEV ]\n"
|
||||
" [ src_vni VNI ]\n"
|
||||
" bridge fdb [ show [ br BRDEV ] [ brport DEV ] [ vlan VID ] [ state STATE ] ]\n"
|
||||
" bridge fdb get ADDR [ br BRDEV ] { brport |dev } DEV [ vlan VID ]\n"
|
||||
" [ vni VNI ]\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
@ -64,10 +62,7 @@ static const char *state_n2a(unsigned int s)
|
|||
if (s & NUD_REACHABLE)
|
||||
return "";
|
||||
|
||||
if (is_json_context())
|
||||
sprintf(buf, "%#x", s);
|
||||
else
|
||||
sprintf(buf, "state=%#x", s);
|
||||
sprintf(buf, "state=%#x", s);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -172,9 +167,6 @@ int print_fdb(struct nlmsghdr *n, void *arg)
|
|||
if (filter_vlan && filter_vlan != vid)
|
||||
return 0;
|
||||
|
||||
if (filter_dynamic && (r->ndm_state & NUD_PERMANENT))
|
||||
return 0;
|
||||
|
||||
open_json_object(NULL);
|
||||
if (n->nlmsg_type == RTM_DELNEIGH)
|
||||
print_bool(PRINT_ANY, "deleted", "Deleted ", true);
|
||||
|
|
@ -192,13 +184,10 @@ int print_fdb(struct nlmsghdr *n, void *arg)
|
|||
"mac", "%s ", lladdr);
|
||||
}
|
||||
|
||||
if (!filter_index && r->ndm_ifindex) {
|
||||
print_string(PRINT_FP, NULL, "dev ", NULL);
|
||||
|
||||
if (!filter_index && r->ndm_ifindex)
|
||||
print_color_string(PRINT_ANY, COLOR_IFNAME,
|
||||
"ifname", "%s ",
|
||||
"ifname", "dev %s ",
|
||||
ll_index_to_name(r->ndm_ifindex));
|
||||
}
|
||||
|
||||
if (tb[NDA_DST]) {
|
||||
int family = AF_INET;
|
||||
|
|
@ -211,11 +200,9 @@ int print_fdb(struct nlmsghdr *n, void *arg)
|
|||
RTA_PAYLOAD(tb[NDA_DST]),
|
||||
RTA_DATA(tb[NDA_DST]));
|
||||
|
||||
print_string(PRINT_FP, NULL, "dst ", NULL);
|
||||
|
||||
print_color_string(PRINT_ANY,
|
||||
ifa_family_color(family),
|
||||
"dst", "%s ", dst);
|
||||
"dst", "dst %s ", dst);
|
||||
}
|
||||
|
||||
if (vid)
|
||||
|
|
@ -250,10 +237,6 @@ int print_fdb(struct nlmsghdr *n, void *arg)
|
|||
ll_index_to_name(ifindex));
|
||||
}
|
||||
|
||||
if (tb[NDA_NH_ID])
|
||||
print_uint(PRINT_ANY, "nhid", "nhid %u ",
|
||||
rta_getattr_u32(tb[NDA_NH_ID]));
|
||||
|
||||
if (tb[NDA_LINK_NETNSID])
|
||||
print_uint(PRINT_ANY,
|
||||
"linkNetNsId", "link-netnsid %d ",
|
||||
|
|
@ -339,8 +322,6 @@ static int fdb_show(int argc, char **argv)
|
|||
if (state_a2n(&state, *argv))
|
||||
invarg("invalid state", *argv);
|
||||
filter_state |= state;
|
||||
} else if (strcmp(*argv, "dynamic") == 0) {
|
||||
filter_dynamic = 1;
|
||||
} else {
|
||||
if (matches(*argv, "help") == 0)
|
||||
usage();
|
||||
|
|
@ -409,7 +390,6 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|||
unsigned int via = 0;
|
||||
char *endptr;
|
||||
short vid = -1;
|
||||
__u32 nhid = 0;
|
||||
|
||||
while (argc > 0) {
|
||||
if (strcmp(*argv, "dev") == 0) {
|
||||
|
|
@ -421,10 +401,6 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|||
duparg2("dst", *argv);
|
||||
get_addr(&dst, *argv, preferred_family);
|
||||
dst_ok = 1;
|
||||
} else if (strcmp(*argv, "nhid") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u32(&nhid, *argv, 0))
|
||||
invarg("\"id\" value is invalid\n", *argv);
|
||||
} else if (strcmp(*argv, "port") == 0) {
|
||||
|
||||
NEXT_ARG();
|
||||
|
|
@ -499,11 +475,6 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (nhid && (dst_ok || port || vni != ~0)) {
|
||||
fprintf(stderr, "dst, port, vni are mutually exclusive with nhid\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Assume self */
|
||||
if (!(req.ndm.ndm_flags&(NTF_SELF|NTF_MASTER)))
|
||||
req.ndm.ndm_flags |= NTF_SELF;
|
||||
|
|
@ -525,8 +496,6 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|||
|
||||
if (vid >= 0)
|
||||
addattr16(&req.n, sizeof(req), NDA_VLAN, vid);
|
||||
if (nhid > 0)
|
||||
addattr32(&req.n, sizeof(req), NDA_NH_ID, nhid);
|
||||
|
||||
if (port) {
|
||||
unsigned short dport;
|
||||
|
|
@ -597,8 +566,6 @@ static int fdb_get(int argc, char **argv)
|
|||
duparg2("vlan", *argv);
|
||||
NEXT_ARG();
|
||||
vlan = atoi(*argv);
|
||||
} else if (matches(*argv, "dynamic") == 0) {
|
||||
filter_dynamic = 1;
|
||||
} else {
|
||||
if (strcmp(*argv, "to") == 0)
|
||||
NEXT_ARG();
|
||||
|
|
@ -652,16 +619,10 @@ static int fdb_get(int argc, char **argv)
|
|||
if (rtnl_talk(&rth, &req.n, &answer) < 0)
|
||||
return -2;
|
||||
|
||||
/*
|
||||
* Initialize a json_writer and open an array object
|
||||
* if -json was specified.
|
||||
*/
|
||||
new_json_obj(json);
|
||||
if (print_fdb(answer, stdout) < 0) {
|
||||
fprintf(stderr, "An error :-)\n");
|
||||
return -1;
|
||||
}
|
||||
delete_json_obj();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
161
bridge/link.c
161
bridge/link.c
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
static unsigned int filter_index;
|
||||
|
||||
static const char *stp_states[] = {
|
||||
static const char *port_states[] = {
|
||||
[BR_STATE_DISABLED] = "disabled",
|
||||
[BR_STATE_LISTENING] = "listening",
|
||||
[BR_STATE_LEARNING] = "learning",
|
||||
|
|
@ -68,29 +68,22 @@ static void print_link_flags(FILE *fp, unsigned int flags, unsigned int mdown)
|
|||
close_json_array(PRINT_ANY, "> ");
|
||||
}
|
||||
|
||||
void print_stp_state(__u8 state)
|
||||
static void print_portstate(__u8 state)
|
||||
{
|
||||
if (state <= BR_STATE_BLOCKING)
|
||||
print_string(PRINT_ANY, "state",
|
||||
"state %s ", stp_states[state]);
|
||||
"state %s ", port_states[state]);
|
||||
else
|
||||
print_uint(PRINT_ANY, "state",
|
||||
"state (%d) ", state);
|
||||
}
|
||||
|
||||
int parse_stp_state(const char *arg)
|
||||
static void print_onoff(FILE *fp, const char *flag, __u8 val)
|
||||
{
|
||||
size_t nstates = ARRAY_SIZE(stp_states);
|
||||
int state;
|
||||
|
||||
for (state = 0; state < nstates; state++)
|
||||
if (strcmp(stp_states[state], arg) == 0)
|
||||
break;
|
||||
|
||||
if (state == nstates)
|
||||
state = -1;
|
||||
|
||||
return state;
|
||||
if (is_json_context())
|
||||
print_bool(PRINT_JSON, flag, NULL, val);
|
||||
else
|
||||
fprintf(fp, "%s %s ", flag, val ? "on" : "off");
|
||||
}
|
||||
|
||||
static void print_hwmode(__u16 mode)
|
||||
|
|
@ -111,7 +104,7 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
|
|||
parse_rtattr_nested(prtb, IFLA_BRPORT_MAX, attr);
|
||||
|
||||
if (prtb[IFLA_BRPORT_STATE])
|
||||
print_stp_state(rta_getattr_u8(prtb[IFLA_BRPORT_STATE]));
|
||||
print_portstate(rta_getattr_u8(prtb[IFLA_BRPORT_STATE]));
|
||||
|
||||
if (prtb[IFLA_BRPORT_PRIORITY])
|
||||
print_uint(PRINT_ANY, "priority",
|
||||
|
|
@ -130,38 +123,38 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
|
|||
fprintf(fp, "%s ", _SL_);
|
||||
|
||||
if (prtb[IFLA_BRPORT_MODE])
|
||||
print_on_off(PRINT_ANY, "hairpin", "hairpin %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_MODE]));
|
||||
print_onoff(fp, "hairpin",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_MODE]));
|
||||
if (prtb[IFLA_BRPORT_GUARD])
|
||||
print_on_off(PRINT_ANY, "guard", "guard %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_GUARD]));
|
||||
print_onoff(fp, "guard",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_GUARD]));
|
||||
if (prtb[IFLA_BRPORT_PROTECT])
|
||||
print_on_off(PRINT_ANY, "root_block", "root_block %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_PROTECT]));
|
||||
print_onoff(fp, "root_block",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_PROTECT]));
|
||||
if (prtb[IFLA_BRPORT_FAST_LEAVE])
|
||||
print_on_off(PRINT_ANY, "fastleave", "fastleave %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_FAST_LEAVE]));
|
||||
print_onoff(fp, "fastleave",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_FAST_LEAVE]));
|
||||
if (prtb[IFLA_BRPORT_LEARNING])
|
||||
print_on_off(PRINT_ANY, "learning", "learning %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING]));
|
||||
print_onoff(fp, "learning",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING]));
|
||||
if (prtb[IFLA_BRPORT_LEARNING_SYNC])
|
||||
print_on_off(PRINT_ANY, "learning_sync", "learning_sync %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING_SYNC]));
|
||||
print_onoff(fp, "learning_sync",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING_SYNC]));
|
||||
if (prtb[IFLA_BRPORT_UNICAST_FLOOD])
|
||||
print_on_off(PRINT_ANY, "flood", "flood %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_UNICAST_FLOOD]));
|
||||
print_onoff(fp, "flood",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_UNICAST_FLOOD]));
|
||||
if (prtb[IFLA_BRPORT_MCAST_FLOOD])
|
||||
print_on_off(PRINT_ANY, "mcast_flood", "mcast_flood %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_FLOOD]));
|
||||
print_onoff(fp, "mcast_flood",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_FLOOD]));
|
||||
if (prtb[IFLA_BRPORT_MCAST_TO_UCAST])
|
||||
print_on_off(PRINT_ANY, "mcast_to_unicast", "mcast_to_unicast %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_TO_UCAST]));
|
||||
print_onoff(fp, "mcast_to_unicast",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_TO_UCAST]));
|
||||
if (prtb[IFLA_BRPORT_NEIGH_SUPPRESS])
|
||||
print_on_off(PRINT_ANY, "neigh_suppress", "neigh_suppress %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_NEIGH_SUPPRESS]));
|
||||
print_onoff(fp, "neigh_suppress",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_NEIGH_SUPPRESS]));
|
||||
if (prtb[IFLA_BRPORT_VLAN_TUNNEL])
|
||||
print_on_off(PRINT_ANY, "vlan_tunnel", "vlan_tunnel %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_VLAN_TUNNEL]));
|
||||
print_onoff(fp, "vlan_tunnel",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_VLAN_TUNNEL]));
|
||||
|
||||
if (prtb[IFLA_BRPORT_BACKUP_PORT]) {
|
||||
int ifidx;
|
||||
|
|
@ -173,10 +166,10 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
|
|||
}
|
||||
|
||||
if (prtb[IFLA_BRPORT_ISOLATED])
|
||||
print_on_off(PRINT_ANY, "isolated", "isolated %s ",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
|
||||
print_onoff(fp, "isolated",
|
||||
rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
|
||||
} else
|
||||
print_stp_state(rta_getattr_u8(attr));
|
||||
print_portstate(rta_getattr_u8(attr));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -282,6 +275,22 @@ static void usage(void)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
static bool on_off(char *arg, __s8 *attr, char *val)
|
||||
{
|
||||
if (strcmp(val, "on") == 0)
|
||||
*attr = 1;
|
||||
else if (strcmp(val, "off") == 0)
|
||||
*attr = 0;
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"Error: argument of \"%s\" must be \"on\" or \"off\"\n",
|
||||
arg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int brlink_modify(int argc, char **argv)
|
||||
{
|
||||
struct {
|
||||
|
|
@ -314,7 +323,6 @@ static int brlink_modify(int argc, char **argv)
|
|||
__s16 mode = -1;
|
||||
__u16 flags = 0;
|
||||
struct rtattr *nest;
|
||||
int ret;
|
||||
|
||||
while (argc > 0) {
|
||||
if (strcmp(*argv, "dev") == 0) {
|
||||
|
|
@ -322,49 +330,40 @@ static int brlink_modify(int argc, char **argv)
|
|||
d = *argv;
|
||||
} else if (strcmp(*argv, "guard") == 0) {
|
||||
NEXT_ARG();
|
||||
bpdu_guard = parse_on_off("guard", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("guard", &bpdu_guard, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "hairpin") == 0) {
|
||||
NEXT_ARG();
|
||||
hairpin = parse_on_off("hairpin", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("hairpin", &hairpin, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "fastleave") == 0) {
|
||||
NEXT_ARG();
|
||||
fast_leave = parse_on_off("fastleave", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("fastleave", &fast_leave, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "root_block") == 0) {
|
||||
NEXT_ARG();
|
||||
root_block = parse_on_off("root_block", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("root_block", &root_block, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "learning") == 0) {
|
||||
NEXT_ARG();
|
||||
learning = parse_on_off("learning", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("learning", &learning, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "learning_sync") == 0) {
|
||||
NEXT_ARG();
|
||||
learning_sync = parse_on_off("learning_sync", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("learning_sync", &learning_sync, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "flood") == 0) {
|
||||
NEXT_ARG();
|
||||
flood = parse_on_off("flood", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("flood", &flood, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "mcast_flood") == 0) {
|
||||
NEXT_ARG();
|
||||
mcast_flood = parse_on_off("mcast_flood", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("mcast_flood", &mcast_flood, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "mcast_to_unicast") == 0) {
|
||||
NEXT_ARG();
|
||||
mcast_to_unicast = parse_on_off("mcast_to_unicast", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("mcast_to_unicast", &mcast_to_unicast, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "cost") == 0) {
|
||||
NEXT_ARG();
|
||||
cost = atoi(*argv);
|
||||
|
|
@ -374,11 +373,14 @@ static int brlink_modify(int argc, char **argv)
|
|||
} else if (strcmp(*argv, "state") == 0) {
|
||||
NEXT_ARG();
|
||||
char *endptr;
|
||||
size_t nstates = ARRAY_SIZE(port_states);
|
||||
|
||||
state = strtol(*argv, &endptr, 10);
|
||||
if (!(**argv != '\0' && *endptr == '\0')) {
|
||||
state = parse_stp_state(*argv);
|
||||
if (state == -1) {
|
||||
for (state = 0; state < nstates; state++)
|
||||
if (strcasecmp(port_states[state], *argv) == 0)
|
||||
break;
|
||||
if (state == nstates) {
|
||||
fprintf(stderr,
|
||||
"Error: invalid STP port state\n");
|
||||
return -1;
|
||||
|
|
@ -402,19 +404,18 @@ static int brlink_modify(int argc, char **argv)
|
|||
flags |= BRIDGE_FLAGS_MASTER;
|
||||
} else if (strcmp(*argv, "neigh_suppress") == 0) {
|
||||
NEXT_ARG();
|
||||
neigh_suppress = parse_on_off("neigh_suppress", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("neigh_suppress", &neigh_suppress,
|
||||
*argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "vlan_tunnel") == 0) {
|
||||
NEXT_ARG();
|
||||
vlan_tunnel = parse_on_off("vlan_tunnel", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("vlan_tunnel", &vlan_tunnel,
|
||||
*argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "isolated") == 0) {
|
||||
NEXT_ARG();
|
||||
isolated = parse_on_off("isolated", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!on_off("isolated", &isolated, *argv))
|
||||
return -1;
|
||||
} else if (strcmp(*argv, "backup_port") == 0) {
|
||||
NEXT_ARG();
|
||||
backup_port_idx = ll_name_to_index(*argv);
|
||||
|
|
|
|||
179
bridge/mdb.c
179
bridge/mdb.c
|
|
@ -16,9 +16,9 @@
|
|||
#include <arpa/inet.h>
|
||||
|
||||
#include "libnetlink.h"
|
||||
#include "utils.h"
|
||||
#include "br_common.h"
|
||||
#include "rt_names.h"
|
||||
#include "utils.h"
|
||||
#include "json_print.h"
|
||||
|
||||
#ifndef MDBA_RTA
|
||||
|
|
@ -31,7 +31,7 @@ static unsigned int filter_index, filter_vlan;
|
|||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [src SOURCE] [permanent | temp] [vid VID]\n"
|
||||
"Usage: bridge mdb { add | del } dev DEV port PORT grp GROUP [permanent | temp] [vid VID]\n"
|
||||
" bridge mdb {show} [ dev DEV ] [ vid VID ]\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
|
@ -41,25 +41,20 @@ static bool is_temp_mcast_rtr(__u8 type)
|
|||
return type == MDB_RTR_TYPE_TEMP_QUERY || type == MDB_RTR_TYPE_TEMP;
|
||||
}
|
||||
|
||||
static const char *format_timer(__u32 ticks, int align)
|
||||
static const char *format_timer(__u32 ticks)
|
||||
{
|
||||
struct timeval tv;
|
||||
static char tbuf[32];
|
||||
|
||||
__jiffies_to_tv(&tv, ticks);
|
||||
if (align)
|
||||
snprintf(tbuf, sizeof(tbuf), "%4lu.%.2lu",
|
||||
(unsigned long)tv.tv_sec,
|
||||
(unsigned long)tv.tv_usec / 10000);
|
||||
else
|
||||
snprintf(tbuf, sizeof(tbuf), "%lu.%.2lu",
|
||||
(unsigned long)tv.tv_sec,
|
||||
(unsigned long)tv.tv_usec / 10000);
|
||||
snprintf(tbuf, sizeof(tbuf), "%4lu.%.2lu",
|
||||
(unsigned long)tv.tv_sec,
|
||||
(unsigned long)tv.tv_usec / 10000);
|
||||
|
||||
return tbuf;
|
||||
}
|
||||
|
||||
void br_print_router_port_stats(struct rtattr *pattr)
|
||||
static void __print_router_port_stats(FILE *f, struct rtattr *pattr)
|
||||
{
|
||||
struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
|
||||
|
||||
|
|
@ -70,7 +65,7 @@ void br_print_router_port_stats(struct rtattr *pattr)
|
|||
__u32 timer = rta_getattr_u32(tb[MDBA_ROUTER_PATTR_TIMER]);
|
||||
|
||||
print_string(PRINT_ANY, "timer", " %s",
|
||||
format_timer(timer, 1));
|
||||
format_timer(timer));
|
||||
}
|
||||
|
||||
if (tb[MDBA_ROUTER_PATTR_TYPE]) {
|
||||
|
|
@ -101,13 +96,13 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr,
|
|||
print_string(PRINT_JSON, "port", NULL, port_ifname);
|
||||
|
||||
if (show_stats)
|
||||
br_print_router_port_stats(i);
|
||||
__print_router_port_stats(f, i);
|
||||
close_json_object();
|
||||
} else if (show_stats) {
|
||||
fprintf(f, "router ports on %s: %s",
|
||||
brifname, port_ifname);
|
||||
|
||||
br_print_router_port_stats(i);
|
||||
__print_router_port_stats(f, i);
|
||||
fprintf(f, "\n");
|
||||
} else {
|
||||
fprintf(f, "%s ", port_ifname);
|
||||
|
|
@ -120,53 +115,20 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr,
|
|||
close_json_array(PRINT_JSON, NULL);
|
||||
}
|
||||
|
||||
static void print_src_entry(struct rtattr *src_attr, int af, const char *sep)
|
||||
{
|
||||
struct rtattr *stb[MDBA_MDB_SRCATTR_MAX + 1];
|
||||
SPRINT_BUF(abuf);
|
||||
const char *addr;
|
||||
__u32 timer_val;
|
||||
|
||||
parse_rtattr_nested(stb, MDBA_MDB_SRCATTR_MAX, src_attr);
|
||||
if (!stb[MDBA_MDB_SRCATTR_ADDRESS] || !stb[MDBA_MDB_SRCATTR_TIMER])
|
||||
return;
|
||||
|
||||
addr = inet_ntop(af, RTA_DATA(stb[MDBA_MDB_SRCATTR_ADDRESS]), abuf,
|
||||
sizeof(abuf));
|
||||
if (!addr)
|
||||
return;
|
||||
timer_val = rta_getattr_u32(stb[MDBA_MDB_SRCATTR_TIMER]);
|
||||
|
||||
open_json_object(NULL);
|
||||
print_string(PRINT_FP, NULL, "%s", sep);
|
||||
print_color_string(PRINT_ANY, ifa_family_color(af),
|
||||
"address", "%s", addr);
|
||||
print_string(PRINT_ANY, "timer", "/%s", format_timer(timer_val, 0));
|
||||
close_json_object();
|
||||
}
|
||||
|
||||
static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
|
||||
struct nlmsghdr *n, struct rtattr **tb)
|
||||
{
|
||||
const void *grp, *src;
|
||||
const char *addr;
|
||||
SPRINT_BUF(abuf);
|
||||
const char *dev;
|
||||
const void *src;
|
||||
int af;
|
||||
|
||||
if (filter_vlan && e->vid != filter_vlan)
|
||||
return;
|
||||
|
||||
if (!e->addr.proto) {
|
||||
af = AF_PACKET;
|
||||
grp = &e->addr.u.mac_addr;
|
||||
} else if (e->addr.proto == htons(ETH_P_IP)) {
|
||||
af = AF_INET;
|
||||
grp = &e->addr.u.ip4;
|
||||
} else {
|
||||
af = AF_INET6;
|
||||
grp = &e->addr.u.ip6;
|
||||
}
|
||||
af = e->addr.proto == htons(ETH_P_IP) ? AF_INET : AF_INET6;
|
||||
src = af == AF_INET ? (const void *)&e->addr.u.ip4 :
|
||||
(const void *)&e->addr.u.ip6;
|
||||
dev = ll_index_to_name(ifindex);
|
||||
|
||||
open_json_object(NULL);
|
||||
|
|
@ -176,64 +138,16 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
|
|||
print_string(PRINT_ANY, "port", " port %s",
|
||||
ll_index_to_name(e->ifindex));
|
||||
|
||||
/* The ETH_ALEN argument is ignored for all cases but AF_PACKET */
|
||||
addr = rt_addr_n2a_r(af, ETH_ALEN, grp, abuf, sizeof(abuf));
|
||||
if (!addr)
|
||||
return;
|
||||
|
||||
print_color_string(PRINT_ANY, ifa_family_color(af),
|
||||
"grp", " grp %s", addr);
|
||||
"grp", " grp %s",
|
||||
inet_ntop(af, src, abuf, sizeof(abuf)));
|
||||
|
||||
if (tb && tb[MDBA_MDB_EATTR_SOURCE]) {
|
||||
src = (const void *)RTA_DATA(tb[MDBA_MDB_EATTR_SOURCE]);
|
||||
print_color_string(PRINT_ANY, ifa_family_color(af),
|
||||
"src", " src %s",
|
||||
inet_ntop(af, src, abuf, sizeof(abuf)));
|
||||
}
|
||||
print_string(PRINT_ANY, "state", " %s",
|
||||
(e->state & MDB_PERMANENT) ? "permanent" : "temp");
|
||||
if (show_details && tb) {
|
||||
if (tb[MDBA_MDB_EATTR_GROUP_MODE]) {
|
||||
__u8 mode = rta_getattr_u8(tb[MDBA_MDB_EATTR_GROUP_MODE]);
|
||||
|
||||
print_string(PRINT_ANY, "filter_mode", " filter_mode %s",
|
||||
mode == MCAST_INCLUDE ? "include" :
|
||||
"exclude");
|
||||
}
|
||||
if (tb[MDBA_MDB_EATTR_SRC_LIST]) {
|
||||
struct rtattr *i, *attr = tb[MDBA_MDB_EATTR_SRC_LIST];
|
||||
const char *sep = " ";
|
||||
int rem;
|
||||
|
||||
open_json_array(PRINT_ANY, is_json_context() ?
|
||||
"source_list" :
|
||||
" source_list");
|
||||
rem = RTA_PAYLOAD(attr);
|
||||
for (i = RTA_DATA(attr); RTA_OK(i, rem);
|
||||
i = RTA_NEXT(i, rem)) {
|
||||
print_src_entry(i, af, sep);
|
||||
sep = ",";
|
||||
}
|
||||
close_json_array(PRINT_JSON, NULL);
|
||||
}
|
||||
if (tb[MDBA_MDB_EATTR_RTPROT]) {
|
||||
__u8 rtprot = rta_getattr_u8(tb[MDBA_MDB_EATTR_RTPROT]);
|
||||
SPRINT_BUF(rtb);
|
||||
|
||||
print_string(PRINT_ANY, "protocol", " proto %s ",
|
||||
rtnl_rtprot_n2a(rtprot, rtb, sizeof(rtb)));
|
||||
}
|
||||
}
|
||||
|
||||
open_json_array(PRINT_JSON, "flags");
|
||||
if (e->flags & MDB_FLAGS_OFFLOAD)
|
||||
print_string(PRINT_ANY, NULL, " %s", "offload");
|
||||
if (e->flags & MDB_FLAGS_FAST_LEAVE)
|
||||
print_string(PRINT_ANY, NULL, " %s", "fast_leave");
|
||||
if (e->flags & MDB_FLAGS_STAR_EXCL)
|
||||
print_string(PRINT_ANY, NULL, " %s", "added_by_star_ex");
|
||||
if (e->flags & MDB_FLAGS_BLOCKED)
|
||||
print_string(PRINT_ANY, NULL, " %s", "blocked");
|
||||
close_json_array(PRINT_JSON, NULL);
|
||||
|
||||
if (e->vid)
|
||||
|
|
@ -243,7 +157,7 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
|
|||
__u32 timer = rta_getattr_u32(tb[MDBA_MDB_EATTR_TIMER]);
|
||||
|
||||
print_string(PRINT_ANY, "timer", " %s",
|
||||
format_timer(timer, 1));
|
||||
format_timer(timer));
|
||||
}
|
||||
|
||||
print_nl();
|
||||
|
|
@ -261,9 +175,8 @@ static void br_print_mdb_entry(FILE *f, int ifindex, struct rtattr *attr,
|
|||
rem = RTA_PAYLOAD(attr);
|
||||
for (i = RTA_DATA(attr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
|
||||
e = RTA_DATA(i);
|
||||
parse_rtattr_flags(etb, MDBA_MDB_EATTR_MAX, MDB_RTA(RTA_DATA(i)),
|
||||
RTA_PAYLOAD(i) - RTA_ALIGN(sizeof(*e)),
|
||||
NLA_F_NESTED);
|
||||
parse_rtattr(etb, MDBA_MDB_EATTR_MAX, MDB_RTA(RTA_DATA(i)),
|
||||
RTA_PAYLOAD(i) - RTA_ALIGN(sizeof(*e)));
|
||||
print_mdb_entry(f, ifindex, e, n, etb);
|
||||
}
|
||||
}
|
||||
|
|
@ -453,25 +366,6 @@ static int mdb_show(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mdb_parse_grp(const char *grp, struct br_mdb_entry *e)
|
||||
{
|
||||
if (inet_pton(AF_INET, grp, &e->addr.u.ip4)) {
|
||||
e->addr.proto = htons(ETH_P_IP);
|
||||
return 0;
|
||||
}
|
||||
if (inet_pton(AF_INET6, grp, &e->addr.u.ip6)) {
|
||||
e->addr.proto = htons(ETH_P_IPV6);
|
||||
return 0;
|
||||
}
|
||||
if (ll_addr_a2n((char *)e->addr.u.mac_addr, sizeof(e->addr.u.mac_addr),
|
||||
grp) == ETH_ALEN) {
|
||||
e->addr.proto = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int mdb_modify(int cmd, int flags, int argc, char **argv)
|
||||
{
|
||||
struct {
|
||||
|
|
@ -484,8 +378,8 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
|
|||
.n.nlmsg_type = cmd,
|
||||
.bpm.family = PF_BRIDGE,
|
||||
};
|
||||
char *d = NULL, *p = NULL, *grp = NULL, *src = NULL;
|
||||
struct br_mdb_entry entry = {};
|
||||
char *d = NULL, *p = NULL, *grp = NULL;
|
||||
short vid = 0;
|
||||
|
||||
while (argc > 0) {
|
||||
|
|
@ -506,9 +400,6 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
|
|||
} else if (strcmp(*argv, "vid") == 0) {
|
||||
NEXT_ARG();
|
||||
vid = atoi(*argv);
|
||||
} else if (strcmp(*argv, "src") == 0) {
|
||||
NEXT_ARG();
|
||||
src = *argv;
|
||||
} else {
|
||||
if (matches(*argv, "help") == 0)
|
||||
usage();
|
||||
|
|
@ -529,31 +420,17 @@ static int mdb_modify(int cmd, int flags, int argc, char **argv)
|
|||
if (!entry.ifindex)
|
||||
return nodev(p);
|
||||
|
||||
if (mdb_parse_grp(grp, &entry)) {
|
||||
fprintf(stderr, "Invalid address \"%s\"\n", grp);
|
||||
return -1;
|
||||
}
|
||||
if (!inet_pton(AF_INET, grp, &entry.addr.u.ip4)) {
|
||||
if (!inet_pton(AF_INET6, grp, &entry.addr.u.ip6)) {
|
||||
fprintf(stderr, "Invalid address \"%s\"\n", grp);
|
||||
return -1;
|
||||
} else
|
||||
entry.addr.proto = htons(ETH_P_IPV6);
|
||||
} else
|
||||
entry.addr.proto = htons(ETH_P_IP);
|
||||
|
||||
entry.vid = vid;
|
||||
addattr_l(&req.n, sizeof(req), MDBA_SET_ENTRY, &entry, sizeof(entry));
|
||||
if (src) {
|
||||
struct rtattr *nest = addattr_nest(&req.n, sizeof(req),
|
||||
MDBA_SET_ENTRY_ATTRS);
|
||||
struct in6_addr src_ip6;
|
||||
__be32 src_ip4;
|
||||
|
||||
nest->rta_type |= NLA_F_NESTED;
|
||||
if (!inet_pton(AF_INET, src, &src_ip4)) {
|
||||
if (!inet_pton(AF_INET6, src, &src_ip6)) {
|
||||
fprintf(stderr, "Invalid source address \"%s\"\n", src);
|
||||
return -1;
|
||||
}
|
||||
addattr_l(&req.n, sizeof(req), MDBE_ATTR_SOURCE, &src_ip6, sizeof(src_ip6));
|
||||
} else {
|
||||
addattr32(&req.n, sizeof(req), MDBE_ATTR_SOURCE, src_ip4);
|
||||
}
|
||||
addattr_nest_end(&req.n, nest);
|
||||
}
|
||||
|
||||
if (rtnl_talk(&rth, &req.n, NULL) < 0)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ static int prefix_banner;
|
|||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: bridge monitor [file | link | fdb | mdb | vlan | all]\n");
|
||||
fprintf(stderr, "Usage: bridge monitor [file | link | fdb | mdb | all]\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
@ -67,12 +67,6 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,
|
|||
print_nlmsg_timestamp(fp, n);
|
||||
return 0;
|
||||
|
||||
case RTM_NEWVLAN:
|
||||
case RTM_DELVLAN:
|
||||
if (prefix_banner)
|
||||
fprintf(fp, "[VLAN]");
|
||||
return print_vlan_rtm(n, arg, true, false);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -85,7 +79,6 @@ int do_monitor(int argc, char **argv)
|
|||
int llink = 0;
|
||||
int lneigh = 0;
|
||||
int lmdb = 0;
|
||||
int lvlan = 0;
|
||||
|
||||
rtnl_close(&rth);
|
||||
|
||||
|
|
@ -102,12 +95,8 @@ int do_monitor(int argc, char **argv)
|
|||
} else if (matches(*argv, "mdb") == 0) {
|
||||
lmdb = 1;
|
||||
groups = 0;
|
||||
} else if (matches(*argv, "vlan") == 0) {
|
||||
lvlan = 1;
|
||||
groups = 0;
|
||||
} else if (strcmp(*argv, "all") == 0) {
|
||||
groups = ~RTMGRP_TC;
|
||||
lvlan = 1;
|
||||
prefix_banner = 1;
|
||||
} else if (matches(*argv, "help") == 0) {
|
||||
usage();
|
||||
|
|
@ -145,12 +134,6 @@ int do_monitor(int argc, char **argv)
|
|||
|
||||
if (rtnl_open(&rth, groups) < 0)
|
||||
exit(1);
|
||||
|
||||
if (lvlan && rtnl_add_nl_group(&rth, RTNLGRP_BRVLAN) < 0) {
|
||||
fprintf(stderr, "Failed to add bridge vlan group to list\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ll_init_map(&rth);
|
||||
|
||||
if (rtnl_listen(&rth, accept_msg, stdout) < 0)
|
||||
|
|
|
|||
697
bridge/vlan.c
697
bridge/vlan.c
|
|
@ -9,7 +9,6 @@
|
|||
#include <linux/if_bridge.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "json_print.h"
|
||||
#include "libnetlink.h"
|
||||
|
|
@ -17,7 +16,6 @@
|
|||
#include "utils.h"
|
||||
|
||||
static unsigned int filter_index, filter_vlan;
|
||||
static int vlan_rtm_cur_ifidx = -1;
|
||||
|
||||
enum vlan_show_subject {
|
||||
VLAN_SHOW_VLAN,
|
||||
|
|
@ -35,24 +33,8 @@ static void usage(void)
|
|||
"Usage: bridge vlan { add | del } vid VLAN_ID dev DEV [ tunnel_info id TUNNEL_ID ]\n"
|
||||
" [ pvid ] [ untagged ]\n"
|
||||
" [ self ] [ master ]\n"
|
||||
" bridge vlan { set } vid VLAN_ID dev DEV [ state STP_STATE ]\n"
|
||||
" [ mcast_router MULTICAST_ROUTER ]\n"
|
||||
" bridge vlan { show } [ dev DEV ] [ vid VLAN_ID ]\n"
|
||||
" bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n"
|
||||
" bridge vlan global { set } vid VLAN_ID dev DEV\n"
|
||||
" [ mcast_snooping MULTICAST_SNOOPING ]\n"
|
||||
" [ mcast_querier MULTICAST_QUERIER ]\n"
|
||||
" [ mcast_igmp_version IGMP_VERSION ]\n"
|
||||
" [ mcast_mld_version MLD_VERSION ]\n"
|
||||
" [ mcast_last_member_count LAST_MEMBER_COUNT ]\n"
|
||||
" [ mcast_last_member_interval LAST_MEMBER_INTERVAL ]\n"
|
||||
" [ mcast_startup_query_count STARTUP_QUERY_COUNT ]\n"
|
||||
" [ mcast_startup_query_interval STARTUP_QUERY_INTERVAL ]\n"
|
||||
" [ mcast_membership_interval MEMBERSHIP_INTERVAL ]\n"
|
||||
" [ mcast_querier_interval QUERIER_INTERVAL ]\n"
|
||||
" [ mcast_query_interval QUERY_INTERVAL ]\n"
|
||||
" [ mcast_query_response_interval QUERY_RESPONSE_INTERVAL ]\n"
|
||||
" bridge vlan global { show } [ dev DEV ] [ vid VLAN_ID ]\n");
|
||||
" bridge vlan { tunnelshow } [ dev DEV ] [ vid VLAN_ID ]\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
@ -259,277 +241,6 @@ static int vlan_modify(int cmd, int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int vlan_option_set(int argc, char **argv)
|
||||
{
|
||||
struct {
|
||||
struct nlmsghdr n;
|
||||
struct br_vlan_msg bvm;
|
||||
char buf[1024];
|
||||
} req = {
|
||||
.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct br_vlan_msg)),
|
||||
.n.nlmsg_flags = NLM_F_REQUEST,
|
||||
.n.nlmsg_type = RTM_NEWVLAN,
|
||||
.bvm.family = PF_BRIDGE,
|
||||
};
|
||||
struct bridge_vlan_info vinfo = {};
|
||||
struct rtattr *afspec;
|
||||
char *d = NULL;
|
||||
short vid = -1;
|
||||
|
||||
afspec = addattr_nest(&req.n, sizeof(req), BRIDGE_VLANDB_ENTRY);
|
||||
afspec->rta_type |= NLA_F_NESTED;
|
||||
while (argc > 0) {
|
||||
if (strcmp(*argv, "dev") == 0) {
|
||||
NEXT_ARG();
|
||||
d = *argv;
|
||||
req.bvm.ifindex = ll_name_to_index(d);
|
||||
if (req.bvm.ifindex == 0) {
|
||||
fprintf(stderr,
|
||||
"Cannot find network device \"%s\"\n",
|
||||
d);
|
||||
return -1;
|
||||
}
|
||||
} else if (strcmp(*argv, "vid") == 0) {
|
||||
short vid_end = -1;
|
||||
char *p;
|
||||
|
||||
NEXT_ARG();
|
||||
p = strchr(*argv, '-');
|
||||
if (p) {
|
||||
*p = '\0';
|
||||
p++;
|
||||
vid = atoi(*argv);
|
||||
vid_end = atoi(p);
|
||||
if (vid >= vid_end || vid_end >= 4096) {
|
||||
fprintf(stderr, "Invalid VLAN range \"%hu-%hu\"\n",
|
||||
vid, vid_end);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
vid = atoi(*argv);
|
||||
}
|
||||
if (vid >= 4096) {
|
||||
fprintf(stderr, "Invalid VLAN ID \"%hu\"\n",
|
||||
vid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vinfo.flags = BRIDGE_VLAN_INFO_ONLY_OPTS;
|
||||
vinfo.vid = vid;
|
||||
addattr_l(&req.n, sizeof(req), BRIDGE_VLANDB_ENTRY_INFO,
|
||||
&vinfo, sizeof(vinfo));
|
||||
if (vid_end != -1)
|
||||
addattr16(&req.n, sizeof(req),
|
||||
BRIDGE_VLANDB_ENTRY_RANGE, vid_end);
|
||||
} else if (strcmp(*argv, "state") == 0) {
|
||||
char *endptr;
|
||||
int state;
|
||||
|
||||
NEXT_ARG();
|
||||
state = strtol(*argv, &endptr, 10);
|
||||
if (!(**argv != '\0' && *endptr == '\0'))
|
||||
state = parse_stp_state(*argv);
|
||||
if (state == -1) {
|
||||
fprintf(stderr, "Error: invalid STP state\n");
|
||||
return -1;
|
||||
}
|
||||
addattr8(&req.n, sizeof(req), BRIDGE_VLANDB_ENTRY_STATE,
|
||||
state);
|
||||
} else if (strcmp(*argv, "mcast_router") == 0) {
|
||||
__u8 mcast_router;
|
||||
|
||||
NEXT_ARG();
|
||||
if (get_u8(&mcast_router, *argv, 0))
|
||||
invarg("invalid mcast_router", *argv);
|
||||
addattr8(&req.n, sizeof(req),
|
||||
BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
|
||||
mcast_router);
|
||||
} else {
|
||||
if (matches(*argv, "help") == 0)
|
||||
NEXT_ARG();
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
addattr_nest_end(&req.n, afspec);
|
||||
|
||||
if (d == NULL || vid == -1) {
|
||||
fprintf(stderr, "Device and VLAN ID are required arguments.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rtnl_talk(&rth, &req.n, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlan_global_option_set(int argc, char **argv)
|
||||
{
|
||||
struct {
|
||||
struct nlmsghdr n;
|
||||
struct br_vlan_msg bvm;
|
||||
char buf[1024];
|
||||
} req = {
|
||||
.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct br_vlan_msg)),
|
||||
.n.nlmsg_flags = NLM_F_REQUEST,
|
||||
.n.nlmsg_type = RTM_NEWVLAN,
|
||||
.bvm.family = PF_BRIDGE,
|
||||
};
|
||||
struct rtattr *afspec;
|
||||
short vid_end = -1;
|
||||
char *d = NULL;
|
||||
short vid = -1;
|
||||
__u64 val64;
|
||||
__u32 val32;
|
||||
__u8 val8;
|
||||
|
||||
afspec = addattr_nest(&req.n, sizeof(req),
|
||||
BRIDGE_VLANDB_GLOBAL_OPTIONS);
|
||||
afspec->rta_type |= NLA_F_NESTED;
|
||||
while (argc > 0) {
|
||||
if (strcmp(*argv, "dev") == 0) {
|
||||
NEXT_ARG();
|
||||
d = *argv;
|
||||
req.bvm.ifindex = ll_name_to_index(d);
|
||||
if (req.bvm.ifindex == 0) {
|
||||
fprintf(stderr, "Cannot find network device \"%s\"\n",
|
||||
d);
|
||||
return -1;
|
||||
}
|
||||
} else if (strcmp(*argv, "vid") == 0) {
|
||||
char *p;
|
||||
|
||||
NEXT_ARG();
|
||||
p = strchr(*argv, '-');
|
||||
if (p) {
|
||||
*p = '\0';
|
||||
p++;
|
||||
vid = atoi(*argv);
|
||||
vid_end = atoi(p);
|
||||
if (vid >= vid_end || vid_end >= 4096) {
|
||||
fprintf(stderr, "Invalid VLAN range \"%hu-%hu\"\n",
|
||||
vid, vid_end);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
vid = atoi(*argv);
|
||||
}
|
||||
if (vid >= 4096) {
|
||||
fprintf(stderr, "Invalid VLAN ID \"%hu\"\n",
|
||||
vid);
|
||||
return -1;
|
||||
}
|
||||
addattr16(&req.n, sizeof(req), BRIDGE_VLANDB_GOPTS_ID,
|
||||
vid);
|
||||
if (vid_end != -1)
|
||||
addattr16(&req.n, sizeof(req),
|
||||
BRIDGE_VLANDB_GOPTS_RANGE, vid_end);
|
||||
} else if (strcmp(*argv, "mcast_snooping") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u8(&val8, *argv, 0))
|
||||
invarg("invalid mcast_snooping", *argv);
|
||||
addattr8(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING, val8);
|
||||
} else if (strcmp(*argv, "mcast_querier") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u8(&val8, *argv, 0))
|
||||
invarg("invalid mcast_querier", *argv);
|
||||
addattr8(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER, val8);
|
||||
} else if (strcmp(*argv, "mcast_igmp_version") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u8(&val8, *argv, 0))
|
||||
invarg("invalid mcast_igmp_version", *argv);
|
||||
addattr8(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION, val8);
|
||||
} else if (strcmp(*argv, "mcast_mld_version") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u8(&val8, *argv, 0))
|
||||
invarg("invalid mcast_mld_version", *argv);
|
||||
addattr8(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION, val8);
|
||||
} else if (strcmp(*argv, "mcast_last_member_count") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u32(&val32, *argv, 0))
|
||||
invarg("invalid mcast_last_member_count", *argv);
|
||||
addattr32(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT,
|
||||
val32);
|
||||
} else if (strcmp(*argv, "mcast_startup_query_count") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u32(&val32, *argv, 0))
|
||||
invarg("invalid mcast_startup_query_count",
|
||||
*argv);
|
||||
addattr32(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT,
|
||||
val32);
|
||||
} else if (strcmp(*argv, "mcast_last_member_interval") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u64(&val64, *argv, 0))
|
||||
invarg("invalid mcast_last_member_interval",
|
||||
*argv);
|
||||
addattr64(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL,
|
||||
val64);
|
||||
} else if (strcmp(*argv, "mcast_membership_interval") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u64(&val64, *argv, 0))
|
||||
invarg("invalid mcast_membership_interval",
|
||||
*argv);
|
||||
addattr64(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL,
|
||||
val64);
|
||||
} else if (strcmp(*argv, "mcast_querier_interval") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u64(&val64, *argv, 0))
|
||||
invarg("invalid mcast_querier_interval",
|
||||
*argv);
|
||||
addattr64(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL,
|
||||
val64);
|
||||
} else if (strcmp(*argv, "mcast_query_interval") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u64(&val64, *argv, 0))
|
||||
invarg("invalid mcast_query_interval",
|
||||
*argv);
|
||||
addattr64(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL,
|
||||
val64);
|
||||
} else if (strcmp(*argv, "mcast_query_response_interval") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u64(&val64, *argv, 0))
|
||||
invarg("invalid mcast_query_response_interval",
|
||||
*argv);
|
||||
addattr64(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL,
|
||||
val64);
|
||||
} else if (strcmp(*argv, "mcast_startup_query_interval") == 0) {
|
||||
NEXT_ARG();
|
||||
if (get_u64(&val64, *argv, 0))
|
||||
invarg("invalid mcast_startup_query_interval",
|
||||
*argv);
|
||||
addattr64(&req.n, 1024,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL,
|
||||
val64);
|
||||
} else {
|
||||
if (strcmp(*argv, "help") == 0)
|
||||
NEXT_ARG();
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
addattr_nest_end(&req.n, afspec);
|
||||
|
||||
if (d == NULL || vid == -1) {
|
||||
fprintf(stderr, "Device and VLAN ID are required arguments.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rtnl_talk(&rth, &req.n, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* In order to use this function for both filtering and non-filtering cases
|
||||
* we need to make it a tristate:
|
||||
* return -1 - if filtering we've gone over so don't continue
|
||||
|
|
@ -711,8 +422,14 @@ static void print_vlan_flags(__u16 flags)
|
|||
close_json_array(PRINT_JSON, NULL);
|
||||
}
|
||||
|
||||
static void __print_one_vlan_stats(const struct bridge_vlan_xstats *vstats)
|
||||
static void print_one_vlan_stats(const struct bridge_vlan_xstats *vstats)
|
||||
{
|
||||
open_json_object(NULL);
|
||||
|
||||
print_hu(PRINT_ANY, "vid", "%hu", vstats->vid);
|
||||
print_vlan_flags(vstats->flags);
|
||||
print_nl();
|
||||
|
||||
print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
|
||||
print_lluint(PRINT_ANY, "rx_bytes", "RX: %llu bytes",
|
||||
vstats->rx_bytes);
|
||||
|
|
@ -724,16 +441,6 @@ static void __print_one_vlan_stats(const struct bridge_vlan_xstats *vstats)
|
|||
vstats->tx_bytes);
|
||||
print_lluint(PRINT_ANY, "tx_packets", " %llu packets\n",
|
||||
vstats->tx_packets);
|
||||
}
|
||||
|
||||
static void print_one_vlan_stats(const struct bridge_vlan_xstats *vstats)
|
||||
{
|
||||
open_json_object(NULL);
|
||||
|
||||
print_hu(PRINT_ANY, "vid", "%hu", vstats->vid);
|
||||
print_vlan_flags(vstats->flags);
|
||||
print_nl();
|
||||
__print_one_vlan_stats(vstats);
|
||||
|
||||
close_json_object();
|
||||
}
|
||||
|
|
@ -814,288 +521,6 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void print_vlan_router_ports(struct rtattr *rattr)
|
||||
{
|
||||
int rem = RTA_PAYLOAD(rattr);
|
||||
struct rtattr *i;
|
||||
|
||||
print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
|
||||
open_json_array(PRINT_ANY, is_json_context() ? "router_ports" :
|
||||
"router ports: ");
|
||||
for (i = RTA_DATA(rattr); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
|
||||
uint32_t *port_ifindex = RTA_DATA(i);
|
||||
const char *port_ifname = ll_index_to_name(*port_ifindex);
|
||||
|
||||
open_json_object(NULL);
|
||||
if (show_stats && i != RTA_DATA(rattr)) {
|
||||
print_nl();
|
||||
/* start: IFNAMSIZ + 4 + strlen("router ports: ") */
|
||||
print_string(PRINT_FP, NULL,
|
||||
"%-" __stringify(IFNAMSIZ) "s "
|
||||
" ",
|
||||
"");
|
||||
}
|
||||
print_string(PRINT_ANY, "port", "%s ", port_ifname);
|
||||
if (show_stats)
|
||||
br_print_router_port_stats(i);
|
||||
close_json_object();
|
||||
}
|
||||
close_json_array(PRINT_JSON, NULL);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
static void print_vlan_global_opts(struct rtattr *a, int ifindex)
|
||||
{
|
||||
struct rtattr *vtb[BRIDGE_VLANDB_GOPTS_MAX + 1], *vattr;
|
||||
__u16 vid, vrange = 0;
|
||||
|
||||
if ((a->rta_type & NLA_TYPE_MASK) != BRIDGE_VLANDB_GLOBAL_OPTIONS)
|
||||
return;
|
||||
|
||||
parse_rtattr_flags(vtb, BRIDGE_VLANDB_GOPTS_MAX, RTA_DATA(a),
|
||||
RTA_PAYLOAD(a), NLA_F_NESTED);
|
||||
vid = rta_getattr_u16(vtb[BRIDGE_VLANDB_GOPTS_ID]);
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_RANGE])
|
||||
vrange = rta_getattr_u16(vtb[BRIDGE_VLANDB_GOPTS_RANGE]);
|
||||
else
|
||||
vrange = vid;
|
||||
|
||||
if (filter_vlan && (filter_vlan < vid || filter_vlan > vrange))
|
||||
return;
|
||||
|
||||
if (vlan_rtm_cur_ifidx != ifindex) {
|
||||
open_vlan_port(ifindex, VLAN_SHOW_VLAN);
|
||||
open_json_object(NULL);
|
||||
vlan_rtm_cur_ifidx = ifindex;
|
||||
} else {
|
||||
open_json_object(NULL);
|
||||
print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
|
||||
}
|
||||
print_range("vlan", vid, vrange);
|
||||
print_nl();
|
||||
print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING];
|
||||
print_uint(PRINT_ANY, "mcast_snooping", "mcast_snooping %u ",
|
||||
rta_getattr_u8(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER];
|
||||
print_uint(PRINT_ANY, "mcast_querier", "mcast_querier %u ",
|
||||
rta_getattr_u8(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION];
|
||||
print_uint(PRINT_ANY, "mcast_igmp_version",
|
||||
"mcast_igmp_version %u ", rta_getattr_u8(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION];
|
||||
print_uint(PRINT_ANY, "mcast_mld_version",
|
||||
"mcast_mld_version %u ", rta_getattr_u8(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT];
|
||||
print_uint(PRINT_ANY, "mcast_last_member_count",
|
||||
"mcast_last_member_count %u ",
|
||||
rta_getattr_u32(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL];
|
||||
print_lluint(PRINT_ANY, "mcast_last_member_interval",
|
||||
"mcast_last_member_interval %llu ",
|
||||
rta_getattr_u64(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT];
|
||||
print_uint(PRINT_ANY, "mcast_startup_query_count",
|
||||
"mcast_startup_query_count %u ",
|
||||
rta_getattr_u32(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL];
|
||||
print_lluint(PRINT_ANY, "mcast_startup_query_interval",
|
||||
"mcast_startup_query_interval %llu ",
|
||||
rta_getattr_u64(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL];
|
||||
print_lluint(PRINT_ANY, "mcast_membership_interval",
|
||||
"mcast_membership_interval %llu ",
|
||||
rta_getattr_u64(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL];
|
||||
print_lluint(PRINT_ANY, "mcast_querier_interval",
|
||||
"mcast_querier_interval %llu ",
|
||||
rta_getattr_u64(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL];
|
||||
print_lluint(PRINT_ANY, "mcast_query_interval",
|
||||
"mcast_query_interval %llu ",
|
||||
rta_getattr_u64(vattr));
|
||||
}
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL];
|
||||
print_lluint(PRINT_ANY, "mcast_query_response_interval",
|
||||
"mcast_query_response_interval %llu ",
|
||||
rta_getattr_u64(vattr));
|
||||
}
|
||||
print_nl();
|
||||
if (vtb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS]) {
|
||||
vattr = RTA_DATA(vtb[BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS]);
|
||||
print_vlan_router_ports(vattr);
|
||||
}
|
||||
close_json_object();
|
||||
}
|
||||
|
||||
static void print_vlan_opts(struct rtattr *a, int ifindex)
|
||||
{
|
||||
struct rtattr *vtb[BRIDGE_VLANDB_ENTRY_MAX + 1], *vattr;
|
||||
struct bridge_vlan_xstats vstats;
|
||||
struct bridge_vlan_info *vinfo;
|
||||
__u16 vrange = 0;
|
||||
__u8 state = 0;
|
||||
|
||||
if ((a->rta_type & NLA_TYPE_MASK) != BRIDGE_VLANDB_ENTRY)
|
||||
return;
|
||||
|
||||
parse_rtattr_flags(vtb, BRIDGE_VLANDB_ENTRY_MAX, RTA_DATA(a),
|
||||
RTA_PAYLOAD(a), NLA_F_NESTED);
|
||||
vinfo = RTA_DATA(vtb[BRIDGE_VLANDB_ENTRY_INFO]);
|
||||
|
||||
memset(&vstats, 0, sizeof(vstats));
|
||||
if (vtb[BRIDGE_VLANDB_ENTRY_RANGE])
|
||||
vrange = rta_getattr_u16(vtb[BRIDGE_VLANDB_ENTRY_RANGE]);
|
||||
else
|
||||
vrange = vinfo->vid;
|
||||
|
||||
if (filter_vlan && (filter_vlan < vinfo->vid || filter_vlan > vrange))
|
||||
return;
|
||||
|
||||
if (vtb[BRIDGE_VLANDB_ENTRY_STATE])
|
||||
state = rta_getattr_u8(vtb[BRIDGE_VLANDB_ENTRY_STATE]);
|
||||
|
||||
if (vtb[BRIDGE_VLANDB_ENTRY_STATS]) {
|
||||
struct rtattr *stb[BRIDGE_VLANDB_STATS_MAX+1];
|
||||
struct rtattr *attr;
|
||||
|
||||
attr = vtb[BRIDGE_VLANDB_ENTRY_STATS];
|
||||
parse_rtattr(stb, BRIDGE_VLANDB_STATS_MAX, RTA_DATA(attr),
|
||||
RTA_PAYLOAD(attr));
|
||||
|
||||
if (stb[BRIDGE_VLANDB_STATS_RX_BYTES]) {
|
||||
attr = stb[BRIDGE_VLANDB_STATS_RX_BYTES];
|
||||
vstats.rx_bytes = rta_getattr_u64(attr);
|
||||
}
|
||||
if (stb[BRIDGE_VLANDB_STATS_RX_PACKETS]) {
|
||||
attr = stb[BRIDGE_VLANDB_STATS_RX_PACKETS];
|
||||
vstats.rx_packets = rta_getattr_u64(attr);
|
||||
}
|
||||
if (stb[BRIDGE_VLANDB_STATS_TX_PACKETS]) {
|
||||
attr = stb[BRIDGE_VLANDB_STATS_TX_PACKETS];
|
||||
vstats.tx_packets = rta_getattr_u64(attr);
|
||||
}
|
||||
if (stb[BRIDGE_VLANDB_STATS_TX_BYTES]) {
|
||||
attr = stb[BRIDGE_VLANDB_STATS_TX_BYTES];
|
||||
vstats.tx_bytes = rta_getattr_u64(attr);
|
||||
}
|
||||
}
|
||||
|
||||
if (vlan_rtm_cur_ifidx != ifindex) {
|
||||
open_vlan_port(ifindex, VLAN_SHOW_VLAN);
|
||||
open_json_object(NULL);
|
||||
vlan_rtm_cur_ifidx = ifindex;
|
||||
} else {
|
||||
open_json_object(NULL);
|
||||
print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
|
||||
}
|
||||
print_range("vlan", vinfo->vid, vrange);
|
||||
print_vlan_flags(vinfo->flags);
|
||||
print_nl();
|
||||
print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
|
||||
print_stp_state(state);
|
||||
if (vtb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]) {
|
||||
vattr = vtb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER];
|
||||
print_uint(PRINT_ANY, "mcast_router", "mcast_router %u ",
|
||||
rta_getattr_u8(vattr));
|
||||
}
|
||||
print_nl();
|
||||
if (show_stats)
|
||||
__print_one_vlan_stats(&vstats);
|
||||
close_json_object();
|
||||
}
|
||||
|
||||
int print_vlan_rtm(struct nlmsghdr *n, void *arg, bool monitor, bool global_only)
|
||||
{
|
||||
struct br_vlan_msg *bvm = NLMSG_DATA(n);
|
||||
int len = n->nlmsg_len;
|
||||
struct rtattr *a;
|
||||
int rem;
|
||||
|
||||
if (n->nlmsg_type != RTM_NEWVLAN && n->nlmsg_type != RTM_DELVLAN &&
|
||||
n->nlmsg_type != RTM_GETVLAN) {
|
||||
fprintf(stderr, "Unknown vlan rtm message: %08x %08x %08x\n",
|
||||
n->nlmsg_len, n->nlmsg_type, n->nlmsg_flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
len -= NLMSG_LENGTH(sizeof(*bvm));
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "BUG: wrong nlmsg len %d\n", len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bvm->family != AF_BRIDGE)
|
||||
return 0;
|
||||
|
||||
if (filter_index && filter_index != bvm->ifindex)
|
||||
return 0;
|
||||
|
||||
if (n->nlmsg_type == RTM_DELVLAN)
|
||||
print_bool(PRINT_ANY, "deleted", "Deleted ", true);
|
||||
|
||||
if (monitor)
|
||||
vlan_rtm_cur_ifidx = -1;
|
||||
|
||||
if (vlan_rtm_cur_ifidx != -1 && vlan_rtm_cur_ifidx != bvm->ifindex) {
|
||||
close_vlan_port();
|
||||
vlan_rtm_cur_ifidx = -1;
|
||||
}
|
||||
|
||||
rem = len;
|
||||
for (a = BRVLAN_RTA(bvm); RTA_OK(a, rem); a = RTA_NEXT(a, rem)) {
|
||||
unsigned short rta_type = a->rta_type & NLA_TYPE_MASK;
|
||||
|
||||
/* skip unknown attributes */
|
||||
if (rta_type > BRIDGE_VLANDB_MAX ||
|
||||
(global_only && rta_type != BRIDGE_VLANDB_GLOBAL_OPTIONS))
|
||||
continue;
|
||||
|
||||
switch (rta_type) {
|
||||
case BRIDGE_VLANDB_ENTRY:
|
||||
print_vlan_opts(a, bvm->ifindex);
|
||||
break;
|
||||
case BRIDGE_VLANDB_GLOBAL_OPTIONS:
|
||||
print_vlan_global_opts(a, bvm->ifindex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_vlan_rtm_filter(struct nlmsghdr *n, void *arg)
|
||||
{
|
||||
return print_vlan_rtm(n, arg, false, false);
|
||||
}
|
||||
|
||||
static int print_vlan_rtm_global_filter(struct nlmsghdr *n, void *arg)
|
||||
{
|
||||
return print_vlan_rtm(n, arg, false, true);
|
||||
}
|
||||
|
||||
static int vlan_show(int argc, char **argv, int subject)
|
||||
{
|
||||
char *filter_dev = NULL;
|
||||
|
|
@ -1124,34 +549,6 @@ static int vlan_show(int argc, char **argv, int subject)
|
|||
|
||||
new_json_obj(json);
|
||||
|
||||
/* if show_details is true then use the new bridge vlan dump format */
|
||||
if (show_details && subject == VLAN_SHOW_VLAN) {
|
||||
__u32 dump_flags = show_stats ? BRIDGE_VLANDB_DUMPF_STATS : 0;
|
||||
|
||||
if (rtnl_brvlandump_req(&rth, PF_BRIDGE, dump_flags) < 0) {
|
||||
perror("Cannot send dump request");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!is_json_context()) {
|
||||
printf("%-" __stringify(IFNAMSIZ) "s %-"
|
||||
__stringify(VLAN_ID_LEN) "s", "port",
|
||||
"vlan-id");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
ret = rtnl_dump_filter(&rth, print_vlan_rtm_filter, &subject);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Dump terminated\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (vlan_rtm_cur_ifidx != -1)
|
||||
close_vlan_port();
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!show_stats) {
|
||||
if (rtnl_linkdump_req_filter(&rth, PF_BRIDGE,
|
||||
(compress_vlans ?
|
||||
|
|
@ -1205,62 +602,6 @@ static int vlan_show(int argc, char **argv, int subject)
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
delete_json_obj();
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlan_global_show(int argc, char **argv)
|
||||
{
|
||||
__u32 dump_flags = BRIDGE_VLANDB_DUMPF_GLOBAL;
|
||||
int ret = 0, subject = VLAN_SHOW_VLAN;
|
||||
char *filter_dev = NULL;
|
||||
|
||||
while (argc > 0) {
|
||||
if (strcmp(*argv, "dev") == 0) {
|
||||
NEXT_ARG();
|
||||
if (filter_dev)
|
||||
duparg("dev", *argv);
|
||||
filter_dev = *argv;
|
||||
} else if (strcmp(*argv, "vid") == 0) {
|
||||
NEXT_ARG();
|
||||
if (filter_vlan)
|
||||
duparg("vid", *argv);
|
||||
filter_vlan = atoi(*argv);
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
|
||||
if (filter_dev) {
|
||||
filter_index = ll_name_to_index(filter_dev);
|
||||
if (!filter_index)
|
||||
return nodev(filter_dev);
|
||||
}
|
||||
|
||||
new_json_obj(json);
|
||||
|
||||
if (rtnl_brvlandump_req(&rth, PF_BRIDGE, dump_flags) < 0) {
|
||||
perror("Cannot send dump request");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!is_json_context()) {
|
||||
printf("%-" __stringify(IFNAMSIZ) "s %-"
|
||||
__stringify(VLAN_ID_LEN) "s", "port",
|
||||
"vlan-id");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
ret = rtnl_dump_filter(&rth, print_vlan_rtm_global_filter, &subject);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "Dump terminated\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (vlan_rtm_cur_ifidx != -1)
|
||||
close_vlan_port();
|
||||
|
||||
delete_json_obj();
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
|
|
@ -1310,24 +651,6 @@ void print_vlan_info(struct rtattr *tb, int ifindex)
|
|||
close_vlan_port();
|
||||
}
|
||||
|
||||
static int vlan_global(int argc, char **argv)
|
||||
{
|
||||
if (argc > 0) {
|
||||
if (strcmp(*argv, "show") == 0 ||
|
||||
strcmp(*argv, "lst") == 0 ||
|
||||
strcmp(*argv, "list") == 0)
|
||||
return vlan_global_show(argc-1, argv+1);
|
||||
else if (strcmp(*argv, "set") == 0)
|
||||
return vlan_global_option_set(argc-1, argv+1);
|
||||
else
|
||||
usage();
|
||||
} else {
|
||||
return vlan_global_show(0, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_vlan(int argc, char **argv)
|
||||
{
|
||||
ll_init_map(&rth);
|
||||
|
|
@ -1344,10 +667,6 @@ int do_vlan(int argc, char **argv)
|
|||
if (matches(*argv, "tunnelshow") == 0) {
|
||||
return vlan_show(argc-1, argv+1, VLAN_SHOW_TUNNELINFO);
|
||||
}
|
||||
if (matches(*argv, "set") == 0)
|
||||
return vlan_option_set(argc-1, argv+1);
|
||||
if (strcmp(*argv, "global") == 0)
|
||||
return vlan_global(argc-1, argv+1);
|
||||
if (matches(*argv, "help") == 0)
|
||||
usage();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# This is not an autoconf generated configure
|
||||
|
||||
INCLUDE="$PWD/include"
|
||||
PREFIX="/usr"
|
||||
LIBDIR="\${prefix}/lib"
|
||||
#
|
||||
INCLUDE=${1:-"$PWD/include"}
|
||||
|
||||
# Output file which is input to Makefile
|
||||
CONFIG=config.mk
|
||||
|
|
@ -150,15 +148,6 @@ EOF
|
|||
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
|
||||
}
|
||||
|
||||
check_lib_dir()
|
||||
{
|
||||
LIBDIR=$(echo $LIBDIR | sed "s|\${prefix}|$PREFIX|")
|
||||
|
||||
echo -n "lib directory: "
|
||||
echo "$LIBDIR"
|
||||
echo "LIBDIR:=$LIBDIR" >> $CONFIG
|
||||
}
|
||||
|
||||
check_ipt()
|
||||
{
|
||||
if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then
|
||||
|
|
@ -208,31 +197,6 @@ EOF
|
|||
rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest
|
||||
}
|
||||
|
||||
check_name_to_handle_at()
|
||||
{
|
||||
cat >$TMPDIR/name_to_handle_at_test.c <<EOF
|
||||
#define _GNU_SOURCE
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct file_handle *fhp;
|
||||
int mount_id, flags, dirfd;
|
||||
char *pathname;
|
||||
name_to_handle_at(dirfd, pathname, fhp, &mount_id, flags);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
if $CC -I$INCLUDE -o $TMPDIR/name_to_handle_at_test $TMPDIR/name_to_handle_at_test.c >/dev/null 2>&1; then
|
||||
echo "yes"
|
||||
echo "CFLAGS += -DHAVE_HANDLE_AT" >>$CONFIG
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
rm -f $TMPDIR/name_to_handle_at_test.c $TMPDIR/name_to_handle_at_test
|
||||
}
|
||||
|
||||
check_ipset()
|
||||
{
|
||||
cat >$TMPDIR/ipsettest.c <<EOF
|
||||
|
|
@ -244,7 +208,7 @@ typedef unsigned short ip_set_id_t;
|
|||
#include <linux/netfilter/xt_set.h>
|
||||
|
||||
struct xt_set_info info;
|
||||
#if IPSET_PROTOCOL == 6 || IPSET_PROTOCOL == 7
|
||||
#if IPSET_PROTOCOL == 6
|
||||
int main(void)
|
||||
{
|
||||
return IPSET_MAXNAMELEN;
|
||||
|
|
@ -276,111 +240,6 @@ check_elf()
|
|||
fi
|
||||
}
|
||||
|
||||
have_libbpf_basic()
|
||||
{
|
||||
cat >$TMPDIR/libbpf_test.c <<EOF
|
||||
#include <bpf/libbpf.h>
|
||||
int main(int argc, char **argv) {
|
||||
bpf_program__set_autoload(NULL, false);
|
||||
bpf_map__ifindex(NULL);
|
||||
bpf_map__set_pin_path(NULL, NULL);
|
||||
bpf_object__open_file(NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
$CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
|
||||
local ret=$?
|
||||
|
||||
rm -f $TMPDIR/libbpf_test.c $TMPDIR/libbpf_test
|
||||
return $ret
|
||||
}
|
||||
|
||||
have_libbpf_sec_name()
|
||||
{
|
||||
cat >$TMPDIR/libbpf_sec_test.c <<EOF
|
||||
#include <bpf/libbpf.h>
|
||||
int main(int argc, char **argv) {
|
||||
void *ptr;
|
||||
bpf_program__section_name(NULL);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
$CC -o $TMPDIR/libbpf_sec_test $TMPDIR/libbpf_sec_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
|
||||
local ret=$?
|
||||
|
||||
rm -f $TMPDIR/libbpf_sec_test.c $TMPDIR/libbpf_sec_test
|
||||
return $ret
|
||||
}
|
||||
|
||||
check_force_libbpf_on()
|
||||
{
|
||||
# if set LIBBPF_FORCE=on but no libbpf support, just exist the config
|
||||
# process to make sure we don't build without libbpf.
|
||||
if [ "$LIBBPF_FORCE" = on ]; then
|
||||
echo " LIBBPF_FORCE=on set, but couldn't find a usable libbpf"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_libbpf()
|
||||
{
|
||||
# if set LIBBPF_FORCE=off, disable libbpf entirely
|
||||
if [ "$LIBBPF_FORCE" = off ]; then
|
||||
echo "no"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! ${PKG_CONFIG} libbpf --exists && [ -z "$LIBBPF_DIR" ] ; then
|
||||
echo "no"
|
||||
check_force_libbpf_on
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $(uname -m) = x86_64 ]; then
|
||||
local LIBBPF_LIBDIR="${LIBBPF_DIR}/usr/lib64"
|
||||
else
|
||||
local LIBBPF_LIBDIR="${LIBBPF_DIR}/usr/lib"
|
||||
fi
|
||||
|
||||
if [ -n "$LIBBPF_DIR" ]; then
|
||||
LIBBPF_CFLAGS="-I${LIBBPF_DIR}/usr/include"
|
||||
LIBBPF_LDLIBS="${LIBBPF_LIBDIR}/libbpf.a -lz -lelf"
|
||||
LIBBPF_VERSION=$(PKG_CONFIG_LIBDIR=${LIBBPF_LIBDIR}/pkgconfig ${PKG_CONFIG} libbpf --modversion)
|
||||
else
|
||||
LIBBPF_CFLAGS=$(${PKG_CONFIG} libbpf --cflags)
|
||||
LIBBPF_LDLIBS=$(${PKG_CONFIG} libbpf --libs)
|
||||
LIBBPF_VERSION=$(${PKG_CONFIG} libbpf --modversion)
|
||||
fi
|
||||
|
||||
if ! have_libbpf_basic; then
|
||||
echo "no"
|
||||
echo " libbpf version $LIBBPF_VERSION is too low, please update it to at least 0.1.0"
|
||||
check_force_libbpf_on
|
||||
return
|
||||
else
|
||||
echo "HAVE_LIBBPF:=y" >> $CONFIG
|
||||
echo 'CFLAGS += -DHAVE_LIBBPF ' $LIBBPF_CFLAGS >> $CONFIG
|
||||
echo "CFLAGS += -DLIBBPF_VERSION=\\\"$LIBBPF_VERSION\\\"" >> $CONFIG
|
||||
echo 'LDLIBS += ' $LIBBPF_LDLIBS >> $CONFIG
|
||||
|
||||
if [ -z "$LIBBPF_DIR" ]; then
|
||||
echo "CFLAGS += -DLIBBPF_DYNAMIC" >> $CONFIG
|
||||
fi
|
||||
fi
|
||||
|
||||
# bpf_program__title() is deprecated since libbpf 0.2.0, use
|
||||
# bpf_program__section_name() instead if we support
|
||||
if have_libbpf_sec_name; then
|
||||
echo "HAVE_LIBBPF_SECTION_NAME:=y" >> $CONFIG
|
||||
echo 'CFLAGS += -DHAVE_LIBBPF_SECTION_NAME ' >> $CONFIG
|
||||
fi
|
||||
|
||||
echo "yes"
|
||||
echo " libbpf version $LIBBPF_VERSION"
|
||||
}
|
||||
|
||||
check_selinux()
|
||||
# SELinux is a compile time option in the ss utility
|
||||
{
|
||||
|
|
@ -492,76 +351,6 @@ endif
|
|||
EOF
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: $0 [OPTIONS]
|
||||
--include_dir <dir> Path to iproute2 include dir
|
||||
--libdir <dir> Path to iproute2 lib dir
|
||||
--libbpf_dir <dir> Path to libbpf DESTDIR
|
||||
--libbpf_force <on|off> Enable/disable libbpf by force. Available options:
|
||||
on: require link against libbpf, quit config if no libbpf support
|
||||
off: disable libbpf probing
|
||||
--prefix <dir> Path prefix of the lib files to install
|
||||
-h | --help Show this usage info
|
||||
EOF
|
||||
exit $1
|
||||
}
|
||||
|
||||
# Compat with the old INCLUDE path setting method.
|
||||
if [ $# -eq 1 ] && [ "$(echo $1 | cut -c 1)" != '-' ]; then
|
||||
INCLUDE="$1"
|
||||
else
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--include_dir)
|
||||
shift
|
||||
INCLUDE="$1" ;;
|
||||
--include_dir=*)
|
||||
INCLUDE="${1#*=}" ;;
|
||||
--libdir)
|
||||
shift
|
||||
LIBDIR="$1" ;;
|
||||
--libdir=*)
|
||||
LIBDIR="${1#*=}" ;;
|
||||
--libbpf_dir)
|
||||
shift
|
||||
LIBBPF_DIR="$1" ;;
|
||||
--libbpf_dir=*)
|
||||
LIBBPF_DIR="${1#*=}" ;;
|
||||
--libbpf_force)
|
||||
shift
|
||||
LIBBPF_FORCE="$1" ;;
|
||||
--libbpf_force=*)
|
||||
LIBBPF_FORCE="${1#*=}" ;;
|
||||
--prefix)
|
||||
shift
|
||||
PREFIX="$1" ;;
|
||||
--prefix=*)
|
||||
PREFIX="${1#*=}" ;;
|
||||
-h | --help)
|
||||
usage 0 ;;
|
||||
--*)
|
||||
;;
|
||||
*)
|
||||
usage 1 ;;
|
||||
esac
|
||||
[ "$#" -gt 0 ] && shift
|
||||
done
|
||||
fi
|
||||
|
||||
[ -d "$INCLUDE" ] || usage 1
|
||||
if [ "${LIBBPF_DIR-unused}" != "unused" ]; then
|
||||
[ -d "$LIBBPF_DIR" ] || usage 1
|
||||
fi
|
||||
if [ "${LIBBPF_FORCE-unused}" != "unused" ]; then
|
||||
if [ "$LIBBPF_FORCE" != 'on' ] && [ "$LIBBPF_FORCE" != 'off' ]; then
|
||||
usage 1
|
||||
fi
|
||||
fi
|
||||
[ -z "$PREFIX" ] && usage 1
|
||||
[ -z "$LIBDIR" ] && usage 1
|
||||
|
||||
echo "# Generated config based on" $INCLUDE >$CONFIG
|
||||
quiet_config >> $CONFIG
|
||||
|
||||
|
|
@ -585,7 +374,6 @@ if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
|
|||
fi
|
||||
|
||||
echo
|
||||
check_lib_dir
|
||||
if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
|
||||
echo -n "iptables modules directory: "
|
||||
check_ipt_lib_dir
|
||||
|
|
@ -594,15 +382,9 @@ fi
|
|||
echo -n "libc has setns: "
|
||||
check_setns
|
||||
|
||||
echo -n "libc has name_to_handle_at: "
|
||||
check_name_to_handle_at
|
||||
|
||||
echo -n "SELinux support: "
|
||||
check_selinux
|
||||
|
||||
echo -n "libbpf support: "
|
||||
check_libbpf
|
||||
|
||||
echo -n "ELF support: "
|
||||
check_elf
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
dcb
|
||||
31
dcb/Makefile
31
dcb/Makefile
|
|
@ -1,31 +0,0 @@
|
|||
# SPDX-License-Identifier: GPL-2.0
|
||||
include ../config.mk
|
||||
|
||||
TARGETS :=
|
||||
|
||||
ifeq ($(HAVE_MNL),y)
|
||||
|
||||
DCBOBJ = dcb.o \
|
||||
dcb_app.o \
|
||||
dcb_buffer.o \
|
||||
dcb_dcbx.o \
|
||||
dcb_ets.o \
|
||||
dcb_maxrate.o \
|
||||
dcb_pfc.o
|
||||
TARGETS += dcb
|
||||
LDLIBS += -lm
|
||||
|
||||
endif
|
||||
|
||||
all: $(TARGETS) $(LIBS)
|
||||
|
||||
dcb: $(DCBOBJ) $(LIBNETLINK)
|
||||
$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||
|
||||
install: all
|
||||
for i in $(TARGETS); \
|
||||
do install -m 0755 $$i $(DESTDIR)$(SBINDIR); \
|
||||
done
|
||||
|
||||
clean:
|
||||
rm -f $(DCBOBJ) $(TARGETS)
|
||||
611
dcb/dcb.c
611
dcb/dcb.c
|
|
@ -1,611 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/dcbnl.h>
|
||||
#include <libmnl/libmnl.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "dcb.h"
|
||||
#include "mnl_utils.h"
|
||||
#include "namespace.h"
|
||||
#include "utils.h"
|
||||
#include "version.h"
|
||||
|
||||
static int dcb_init(struct dcb *dcb)
|
||||
{
|
||||
dcb->buf = malloc(MNL_SOCKET_BUFFER_SIZE);
|
||||
if (dcb->buf == NULL) {
|
||||
perror("Netlink buffer allocation");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dcb->nl = mnlu_socket_open(NETLINK_ROUTE);
|
||||
if (dcb->nl == NULL) {
|
||||
perror("Open netlink socket");
|
||||
goto err_socket_open;
|
||||
}
|
||||
|
||||
new_json_obj_plain(dcb->json_output);
|
||||
return 0;
|
||||
|
||||
err_socket_open:
|
||||
free(dcb->buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void dcb_fini(struct dcb *dcb)
|
||||
{
|
||||
delete_json_obj_plain();
|
||||
mnl_socket_close(dcb->nl);
|
||||
free(dcb->buf);
|
||||
}
|
||||
|
||||
static struct dcb *dcb_alloc(void)
|
||||
{
|
||||
struct dcb *dcb;
|
||||
|
||||
dcb = calloc(1, sizeof(*dcb));
|
||||
if (!dcb)
|
||||
return NULL;
|
||||
return dcb;
|
||||
}
|
||||
|
||||
static void dcb_free(struct dcb *dcb)
|
||||
{
|
||||
free(dcb);
|
||||
}
|
||||
|
||||
struct dcb_get_attribute {
|
||||
struct dcb *dcb;
|
||||
int attr;
|
||||
void *payload;
|
||||
__u16 payload_len;
|
||||
};
|
||||
|
||||
static int dcb_get_attribute_attr_ieee_cb(const struct nlattr *attr, void *data)
|
||||
{
|
||||
struct dcb_get_attribute *ga = data;
|
||||
|
||||
if (mnl_attr_get_type(attr) != ga->attr)
|
||||
return MNL_CB_OK;
|
||||
|
||||
ga->payload = mnl_attr_get_payload(attr);
|
||||
ga->payload_len = mnl_attr_get_payload_len(attr);
|
||||
return MNL_CB_STOP;
|
||||
}
|
||||
|
||||
static int dcb_get_attribute_attr_cb(const struct nlattr *attr, void *data)
|
||||
{
|
||||
if (mnl_attr_get_type(attr) != DCB_ATTR_IEEE)
|
||||
return MNL_CB_OK;
|
||||
|
||||
return mnl_attr_parse_nested(attr, dcb_get_attribute_attr_ieee_cb, data);
|
||||
}
|
||||
|
||||
static int dcb_get_attribute_cb(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
return mnl_attr_parse(nlh, sizeof(struct dcbmsg), dcb_get_attribute_attr_cb, data);
|
||||
}
|
||||
|
||||
static int dcb_get_attribute_bare_cb(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
/* Bare attributes (e.g. DCB_ATTR_DCBX) are not wrapped inside an IEEE
|
||||
* container, so this does not have to go through unpacking in
|
||||
* dcb_get_attribute_attr_cb().
|
||||
*/
|
||||
return mnl_attr_parse(nlh, sizeof(struct dcbmsg),
|
||||
dcb_get_attribute_attr_ieee_cb, data);
|
||||
}
|
||||
|
||||
struct dcb_set_attribute_response {
|
||||
int response_attr;
|
||||
};
|
||||
|
||||
static int dcb_set_attribute_attr_cb(const struct nlattr *attr, void *data)
|
||||
{
|
||||
struct dcb_set_attribute_response *resp = data;
|
||||
uint16_t len;
|
||||
uint8_t err;
|
||||
|
||||
if (mnl_attr_get_type(attr) != resp->response_attr)
|
||||
return MNL_CB_OK;
|
||||
|
||||
len = mnl_attr_get_payload_len(attr);
|
||||
if (len != 1) {
|
||||
fprintf(stderr, "Response attribute expected to have size 1, not %d\n", len);
|
||||
return MNL_CB_ERROR;
|
||||
}
|
||||
|
||||
err = mnl_attr_get_u8(attr);
|
||||
if (err) {
|
||||
fprintf(stderr, "Error when attempting to set attribute: %s\n",
|
||||
strerror(err));
|
||||
return MNL_CB_ERROR;
|
||||
}
|
||||
|
||||
return MNL_CB_STOP;
|
||||
}
|
||||
|
||||
static int dcb_set_attribute_cb(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
return mnl_attr_parse(nlh, sizeof(struct dcbmsg), dcb_set_attribute_attr_cb, data);
|
||||
}
|
||||
|
||||
static int dcb_talk(struct dcb *dcb, struct nlmsghdr *nlh, mnl_cb_t cb, void *data)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = mnl_socket_sendto(dcb->nl, nlh, nlh->nlmsg_len);
|
||||
if (ret < 0) {
|
||||
perror("mnl_socket_sendto");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return mnlu_socket_recv_run(dcb->nl, nlh->nlmsg_seq, dcb->buf, MNL_SOCKET_BUFFER_SIZE,
|
||||
cb, data);
|
||||
}
|
||||
|
||||
static struct nlmsghdr *dcb_prepare(struct dcb *dcb, const char *dev,
|
||||
uint32_t nlmsg_type, uint8_t dcb_cmd)
|
||||
{
|
||||
struct dcbmsg dcbm = {
|
||||
.cmd = dcb_cmd,
|
||||
};
|
||||
struct nlmsghdr *nlh;
|
||||
|
||||
nlh = mnlu_msg_prepare(dcb->buf, nlmsg_type, NLM_F_REQUEST, &dcbm, sizeof(dcbm));
|
||||
mnl_attr_put_strz(nlh, DCB_ATTR_IFNAME, dev);
|
||||
return nlh;
|
||||
}
|
||||
|
||||
static int __dcb_get_attribute(struct dcb *dcb, int command,
|
||||
const char *dev, int attr,
|
||||
void **payload_p, __u16 *payload_len_p,
|
||||
int (*get_attribute_cb)(const struct nlmsghdr *nlh,
|
||||
void *data))
|
||||
{
|
||||
struct dcb_get_attribute ga;
|
||||
struct nlmsghdr *nlh;
|
||||
int ret;
|
||||
|
||||
nlh = dcb_prepare(dcb, dev, RTM_GETDCB, command);
|
||||
|
||||
ga = (struct dcb_get_attribute) {
|
||||
.dcb = dcb,
|
||||
.attr = attr,
|
||||
.payload = NULL,
|
||||
};
|
||||
ret = dcb_talk(dcb, nlh, get_attribute_cb, &ga);
|
||||
if (ret) {
|
||||
perror("Attribute read");
|
||||
return ret;
|
||||
}
|
||||
if (ga.payload == NULL) {
|
||||
perror("Attribute not found");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
*payload_p = ga.payload;
|
||||
*payload_len_p = ga.payload_len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_get_attribute_va(struct dcb *dcb, const char *dev, int attr,
|
||||
void **payload_p, __u16 *payload_len_p)
|
||||
{
|
||||
return __dcb_get_attribute(dcb, DCB_CMD_IEEE_GET, dev, attr,
|
||||
payload_p, payload_len_p,
|
||||
dcb_get_attribute_cb);
|
||||
}
|
||||
|
||||
int dcb_get_attribute_bare(struct dcb *dcb, int cmd, const char *dev, int attr,
|
||||
void **payload_p, __u16 *payload_len_p)
|
||||
{
|
||||
return __dcb_get_attribute(dcb, cmd, dev, attr,
|
||||
payload_p, payload_len_p,
|
||||
dcb_get_attribute_bare_cb);
|
||||
}
|
||||
|
||||
int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr, void *data, size_t data_len)
|
||||
{
|
||||
__u16 payload_len;
|
||||
void *payload;
|
||||
int ret;
|
||||
|
||||
ret = dcb_get_attribute_va(dcb, dev, attr, &payload, &payload_len);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (payload_len != data_len) {
|
||||
fprintf(stderr, "Wrong len %d, expected %zd\n", payload_len, data_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memcpy(data, payload, data_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __dcb_set_attribute(struct dcb *dcb, int command, const char *dev,
|
||||
int (*cb)(struct dcb *, struct nlmsghdr *, void *),
|
||||
void *data, int response_attr)
|
||||
{
|
||||
struct dcb_set_attribute_response resp = {
|
||||
.response_attr = response_attr,
|
||||
};
|
||||
struct nlmsghdr *nlh;
|
||||
int ret;
|
||||
|
||||
nlh = dcb_prepare(dcb, dev, RTM_SETDCB, command);
|
||||
|
||||
ret = cb(dcb, nlh, data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = dcb_talk(dcb, nlh, dcb_set_attribute_cb, &resp);
|
||||
if (ret) {
|
||||
perror("Attribute write");
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct dcb_set_attribute_ieee_cb {
|
||||
int (*cb)(struct dcb *dcb, struct nlmsghdr *nlh, void *data);
|
||||
void *data;
|
||||
};
|
||||
|
||||
static int dcb_set_attribute_ieee_cb(struct dcb *dcb, struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
struct dcb_set_attribute_ieee_cb *ieee_data = data;
|
||||
struct nlattr *nest;
|
||||
int ret;
|
||||
|
||||
nest = mnl_attr_nest_start(nlh, DCB_ATTR_IEEE);
|
||||
ret = ieee_data->cb(dcb, nlh, ieee_data->data);
|
||||
if (ret)
|
||||
return ret;
|
||||
mnl_attr_nest_end(nlh, nest);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_set_attribute_va(struct dcb *dcb, int command, const char *dev,
|
||||
int (*cb)(struct dcb *dcb, struct nlmsghdr *nlh, void *data),
|
||||
void *data)
|
||||
{
|
||||
struct dcb_set_attribute_ieee_cb ieee_data = {
|
||||
.cb = cb,
|
||||
.data = data,
|
||||
};
|
||||
|
||||
return __dcb_set_attribute(dcb, command, dev,
|
||||
&dcb_set_attribute_ieee_cb, &ieee_data,
|
||||
DCB_ATTR_IEEE);
|
||||
}
|
||||
|
||||
struct dcb_set_attribute {
|
||||
int attr;
|
||||
const void *data;
|
||||
size_t data_len;
|
||||
};
|
||||
|
||||
static int dcb_set_attribute_put(struct dcb *dcb, struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
struct dcb_set_attribute *dsa = data;
|
||||
|
||||
mnl_attr_put(nlh, dsa->attr, dsa->data_len, dsa->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr, const void *data, size_t data_len)
|
||||
{
|
||||
struct dcb_set_attribute dsa = {
|
||||
.attr = attr,
|
||||
.data = data,
|
||||
.data_len = data_len,
|
||||
};
|
||||
|
||||
return dcb_set_attribute_va(dcb, DCB_CMD_IEEE_SET, dev,
|
||||
&dcb_set_attribute_put, &dsa);
|
||||
}
|
||||
|
||||
int dcb_set_attribute_bare(struct dcb *dcb, int command, const char *dev,
|
||||
int attr, const void *data, size_t data_len,
|
||||
int response_attr)
|
||||
{
|
||||
struct dcb_set_attribute dsa = {
|
||||
.attr = attr,
|
||||
.data = data,
|
||||
.data_len = data_len,
|
||||
};
|
||||
|
||||
return __dcb_set_attribute(dcb, command, dev,
|
||||
&dcb_set_attribute_put, &dsa, response_attr);
|
||||
}
|
||||
|
||||
void dcb_print_array_u8(const __u8 *array, size_t size)
|
||||
{
|
||||
SPRINT_BUF(b);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
snprintf(b, sizeof(b), "%zd:%%d ", i);
|
||||
print_uint(PRINT_ANY, NULL, b, array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void dcb_print_array_u64(const __u64 *array, size_t size)
|
||||
{
|
||||
SPRINT_BUF(b);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
snprintf(b, sizeof(b), "%zd:%%" PRIu64 " ", i);
|
||||
print_u64(PRINT_ANY, NULL, b, array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void dcb_print_array_on_off(const __u8 *array, size_t size)
|
||||
{
|
||||
SPRINT_BUF(b);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
snprintf(b, sizeof(b), "%zd:%%s ", i);
|
||||
print_on_off(PRINT_ANY, NULL, b, array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void dcb_print_array_kw(const __u8 *array, size_t array_size,
|
||||
const char *const kw[], size_t kw_size)
|
||||
{
|
||||
SPRINT_BUF(b);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < array_size; i++) {
|
||||
__u8 emt = array[i];
|
||||
|
||||
snprintf(b, sizeof(b), "%zd:%%s ", i);
|
||||
if (emt < kw_size && kw[emt])
|
||||
print_string(PRINT_ANY, NULL, b, kw[emt]);
|
||||
else
|
||||
print_string(PRINT_ANY, NULL, b, "???");
|
||||
}
|
||||
}
|
||||
|
||||
void dcb_print_named_array(const char *json_name, const char *fp_name,
|
||||
const __u8 *array, size_t size,
|
||||
void (*print_array)(const __u8 *, size_t))
|
||||
{
|
||||
open_json_array(PRINT_JSON, json_name);
|
||||
print_string(PRINT_FP, NULL, "%s ", fp_name);
|
||||
print_array(array, size);
|
||||
close_json_array(PRINT_JSON, json_name);
|
||||
}
|
||||
|
||||
int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
|
||||
const char *what_value, __u64 value, __u64 max_value,
|
||||
void (*set_array)(__u32 index, __u64 value, void *data),
|
||||
void *set_array_data)
|
||||
{
|
||||
bool is_all = key == (__u32) -1;
|
||||
|
||||
if (!is_all && key > max_key) {
|
||||
fprintf(stderr, "In %s:%s mapping, %s is expected to be 0..%d\n",
|
||||
what_key, what_value, what_key, max_key);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (value > max_value) {
|
||||
fprintf(stderr, "In %s:%s mapping, %s is expected to be 0..%llu\n",
|
||||
what_key, what_value, what_value, max_value);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (is_all) {
|
||||
for (key = 0; key <= max_key; key++)
|
||||
set_array(key, value, set_array_data);
|
||||
} else {
|
||||
set_array(key, value, set_array_data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dcb_set_u8(__u32 key, __u64 value, void *data)
|
||||
{
|
||||
__u8 *array = data;
|
||||
|
||||
array[key] = value;
|
||||
}
|
||||
|
||||
void dcb_set_u32(__u32 key, __u64 value, void *data)
|
||||
{
|
||||
__u32 *array = data;
|
||||
|
||||
array[key] = value;
|
||||
}
|
||||
|
||||
void dcb_set_u64(__u32 key, __u64 value, void *data)
|
||||
{
|
||||
__u64 *array = data;
|
||||
|
||||
array[key] = value;
|
||||
}
|
||||
|
||||
int dcb_cmd_parse_dev(struct dcb *dcb, int argc, char **argv,
|
||||
int (*and_then)(struct dcb *dcb, const char *dev,
|
||||
int argc, char **argv),
|
||||
void (*help)(void))
|
||||
{
|
||||
const char *dev;
|
||||
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "dev") == 0) {
|
||||
NEXT_ARG();
|
||||
dev = *argv;
|
||||
if (check_ifname(dev)) {
|
||||
invarg("not a valid ifname", *argv);
|
||||
return -EINVAL;
|
||||
}
|
||||
NEXT_ARG_FWD();
|
||||
return and_then(dcb, dev, argc, argv);
|
||||
} else {
|
||||
fprintf(stderr, "Expected `dev DEV', not `%s'", *argv);
|
||||
help();
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
static void dcb_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||
" dcb [ -f | --force ] { -b | --batch } filename [ -n | --netns ] netnsname\n"
|
||||
"where OBJECT := { app | buffer | dcbx | ets | maxrate | pfc }\n"
|
||||
" OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n"
|
||||
" | -N | --Numeric | -p | --pretty\n"
|
||||
" | -s | --statistics | -v | --verbose]\n");
|
||||
}
|
||||
|
||||
static int dcb_cmd(struct dcb *dcb, int argc, char **argv)
|
||||
{
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
dcb_help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "app") == 0) {
|
||||
return dcb_cmd_app(dcb, argc - 1, argv + 1);
|
||||
} else if (matches(*argv, "buffer") == 0) {
|
||||
return dcb_cmd_buffer(dcb, argc - 1, argv + 1);
|
||||
} else if (matches(*argv, "dcbx") == 0) {
|
||||
return dcb_cmd_dcbx(dcb, argc - 1, argv + 1);
|
||||
} else if (matches(*argv, "ets") == 0) {
|
||||
return dcb_cmd_ets(dcb, argc - 1, argv + 1);
|
||||
} else if (matches(*argv, "maxrate") == 0) {
|
||||
return dcb_cmd_maxrate(dcb, argc - 1, argv + 1);
|
||||
} else if (matches(*argv, "pfc") == 0) {
|
||||
return dcb_cmd_pfc(dcb, argc - 1, argv + 1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Object \"%s\" is unknown\n", *argv);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int dcb_batch_cmd(int argc, char *argv[], void *data)
|
||||
{
|
||||
struct dcb *dcb = data;
|
||||
|
||||
return dcb_cmd(dcb, argc, argv);
|
||||
}
|
||||
|
||||
static int dcb_batch(struct dcb *dcb, const char *name, bool force)
|
||||
{
|
||||
return do_batch(name, force, dcb_batch_cmd, dcb);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static const struct option long_options[] = {
|
||||
{ "Version", no_argument, NULL, 'V' },
|
||||
{ "force", no_argument, NULL, 'f' },
|
||||
{ "batch", required_argument, NULL, 'b' },
|
||||
{ "iec", no_argument, NULL, 'i' },
|
||||
{ "json", no_argument, NULL, 'j' },
|
||||
{ "Numeric", no_argument, NULL, 'N' },
|
||||
{ "pretty", no_argument, NULL, 'p' },
|
||||
{ "statistics", no_argument, NULL, 's' },
|
||||
{ "netns", required_argument, NULL, 'n' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
const char *batch_file = NULL;
|
||||
bool force = false;
|
||||
struct dcb *dcb;
|
||||
int opt;
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
dcb = dcb_alloc();
|
||||
if (!dcb) {
|
||||
fprintf(stderr, "Failed to allocate memory for dcb\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "b:fhijn:psvNV",
|
||||
long_options, NULL)) >= 0) {
|
||||
|
||||
switch (opt) {
|
||||
case 'V':
|
||||
printf("dcb utility, iproute2-%s\n", version);
|
||||
ret = EXIT_SUCCESS;
|
||||
goto dcb_free;
|
||||
case 'f':
|
||||
force = true;
|
||||
break;
|
||||
case 'b':
|
||||
batch_file = optarg;
|
||||
break;
|
||||
case 'j':
|
||||
dcb->json_output = true;
|
||||
break;
|
||||
case 'N':
|
||||
dcb->numeric = true;
|
||||
break;
|
||||
case 'p':
|
||||
pretty = true;
|
||||
break;
|
||||
case 's':
|
||||
dcb->stats = true;
|
||||
break;
|
||||
case 'n':
|
||||
if (netns_switch(optarg)) {
|
||||
ret = EXIT_FAILURE;
|
||||
goto dcb_free;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
dcb->use_iec = true;
|
||||
break;
|
||||
case 'h':
|
||||
dcb_help();
|
||||
ret = EXIT_SUCCESS;
|
||||
goto dcb_free;
|
||||
default:
|
||||
fprintf(stderr, "Unknown option.\n");
|
||||
dcb_help();
|
||||
ret = EXIT_FAILURE;
|
||||
goto dcb_free;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
err = dcb_init(dcb);
|
||||
if (err) {
|
||||
ret = EXIT_FAILURE;
|
||||
goto dcb_free;
|
||||
}
|
||||
|
||||
if (batch_file)
|
||||
err = dcb_batch(dcb, batch_file, force);
|
||||
else
|
||||
err = dcb_cmd(dcb, argc, argv);
|
||||
|
||||
if (err) {
|
||||
ret = EXIT_FAILURE;
|
||||
goto dcb_fini;
|
||||
}
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
|
||||
dcb_fini:
|
||||
dcb_fini(dcb);
|
||||
dcb_free:
|
||||
dcb_free(dcb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
81
dcb/dcb.h
81
dcb/dcb.h
|
|
@ -1,81 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef __DCB_H__
|
||||
#define __DCB_H__ 1
|
||||
|
||||
#include <libmnl/libmnl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* dcb.c */
|
||||
|
||||
struct dcb {
|
||||
char *buf;
|
||||
struct mnl_socket *nl;
|
||||
bool json_output;
|
||||
bool stats;
|
||||
bool use_iec;
|
||||
bool numeric;
|
||||
};
|
||||
|
||||
int dcb_parse_mapping(const char *what_key, __u32 key, __u32 max_key,
|
||||
const char *what_value, __u64 value, __u64 max_value,
|
||||
void (*set_array)(__u32 index, __u64 value, void *data),
|
||||
void *set_array_data);
|
||||
int dcb_cmd_parse_dev(struct dcb *dcb, int argc, char **argv,
|
||||
int (*and_then)(struct dcb *dcb, const char *dev,
|
||||
int argc, char **argv),
|
||||
void (*help)(void));
|
||||
|
||||
void dcb_set_u8(__u32 key, __u64 value, void *data);
|
||||
void dcb_set_u32(__u32 key, __u64 value, void *data);
|
||||
void dcb_set_u64(__u32 key, __u64 value, void *data);
|
||||
|
||||
int dcb_get_attribute(struct dcb *dcb, const char *dev, int attr,
|
||||
void *data, size_t data_len);
|
||||
int dcb_set_attribute(struct dcb *dcb, const char *dev, int attr,
|
||||
const void *data, size_t data_len);
|
||||
int dcb_get_attribute_va(struct dcb *dcb, const char *dev, int attr,
|
||||
void **payload_p, __u16 *payload_len_p);
|
||||
int dcb_set_attribute_va(struct dcb *dcb, int command, const char *dev,
|
||||
int (*cb)(struct dcb *dcb, struct nlmsghdr *nlh, void *data),
|
||||
void *data);
|
||||
int dcb_get_attribute_bare(struct dcb *dcb, int cmd, const char *dev, int attr,
|
||||
void **payload_p, __u16 *payload_len_p);
|
||||
int dcb_set_attribute_bare(struct dcb *dcb, int command, const char *dev,
|
||||
int attr, const void *data, size_t data_len,
|
||||
int response_attr);
|
||||
|
||||
void dcb_print_named_array(const char *json_name, const char *fp_name,
|
||||
const __u8 *array, size_t size,
|
||||
void (*print_array)(const __u8 *, size_t));
|
||||
void dcb_print_array_u8(const __u8 *array, size_t size);
|
||||
void dcb_print_array_u64(const __u64 *array, size_t size);
|
||||
void dcb_print_array_on_off(const __u8 *array, size_t size);
|
||||
void dcb_print_array_kw(const __u8 *array, size_t array_size,
|
||||
const char *const kw[], size_t kw_size);
|
||||
|
||||
/* dcb_app.c */
|
||||
|
||||
int dcb_cmd_app(struct dcb *dcb, int argc, char **argv);
|
||||
|
||||
/* dcb_buffer.c */
|
||||
|
||||
int dcb_cmd_buffer(struct dcb *dcb, int argc, char **argv);
|
||||
|
||||
/* dcb_dcbx.c */
|
||||
|
||||
int dcb_cmd_dcbx(struct dcb *dcb, int argc, char **argv);
|
||||
|
||||
/* dcb_ets.c */
|
||||
|
||||
int dcb_cmd_ets(struct dcb *dcb, int argc, char **argv);
|
||||
|
||||
/* dcb_maxrate.c */
|
||||
|
||||
int dcb_cmd_maxrate(struct dcb *dcb, int argc, char **argv);
|
||||
|
||||
/* dcb_pfc.c */
|
||||
|
||||
int dcb_cmd_pfc(struct dcb *dcb, int argc, char **argv);
|
||||
|
||||
#endif /* __DCB_H__ */
|
||||
795
dcb/dcb_app.c
795
dcb/dcb_app.c
|
|
@ -1,795 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <libmnl/libmnl.h>
|
||||
#include <linux/dcbnl.h>
|
||||
|
||||
#include "dcb.h"
|
||||
#include "utils.h"
|
||||
#include "rt_names.h"
|
||||
|
||||
static void dcb_app_help_add(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb app { add | del | replace } dev STRING\n"
|
||||
" [ default-prio PRIO ]\n"
|
||||
" [ ethtype-prio ET:PRIO ]\n"
|
||||
" [ stream-port-prio PORT:PRIO ]\n"
|
||||
" [ dgram-port-prio PORT:PRIO ]\n"
|
||||
" [ port-prio PORT:PRIO ]\n"
|
||||
" [ dscp-prio INTEGER:PRIO ]\n"
|
||||
"\n"
|
||||
" where PRIO := { 0 .. 7 }\n"
|
||||
" ET := { 0x600 .. 0xffff }\n"
|
||||
" PORT := { 1 .. 65535 }\n"
|
||||
" DSCP := { 0 .. 63 }\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_app_help_show_flush(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb app { show | flush } dev STRING\n"
|
||||
" [ default-prio ]\n"
|
||||
" [ ethtype-prio ]\n"
|
||||
" [ stream-port-prio ]\n"
|
||||
" [ dgram-port-prio ]\n"
|
||||
" [ port-prio ]\n"
|
||||
" [ dscp-prio ]\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_app_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb app help\n"
|
||||
"\n"
|
||||
);
|
||||
dcb_app_help_show_flush();
|
||||
dcb_app_help_add();
|
||||
}
|
||||
|
||||
struct dcb_app_table {
|
||||
struct dcb_app *apps;
|
||||
size_t n_apps;
|
||||
};
|
||||
|
||||
static void dcb_app_table_fini(struct dcb_app_table *tab)
|
||||
{
|
||||
free(tab->apps);
|
||||
}
|
||||
|
||||
static int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app)
|
||||
{
|
||||
struct dcb_app *apps = realloc(tab->apps, (tab->n_apps + 1) * sizeof(*tab->apps));
|
||||
|
||||
if (apps == NULL) {
|
||||
perror("Cannot allocate APP table");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
tab->apps = apps;
|
||||
tab->apps[tab->n_apps++] = *app;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dcb_app_table_remove_existing(struct dcb_app_table *a,
|
||||
const struct dcb_app_table *b)
|
||||
{
|
||||
size_t ia, ja;
|
||||
size_t ib;
|
||||
|
||||
for (ia = 0, ja = 0; ia < a->n_apps; ia++) {
|
||||
struct dcb_app *aa = &a->apps[ia];
|
||||
bool found = false;
|
||||
|
||||
for (ib = 0; ib < b->n_apps; ib++) {
|
||||
const struct dcb_app *ab = &b->apps[ib];
|
||||
|
||||
if (aa->selector == ab->selector &&
|
||||
aa->protocol == ab->protocol &&
|
||||
aa->priority == ab->priority) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
a->apps[ja++] = *aa;
|
||||
}
|
||||
|
||||
a->n_apps = ja;
|
||||
}
|
||||
|
||||
static void dcb_app_table_remove_replaced(struct dcb_app_table *a,
|
||||
const struct dcb_app_table *b)
|
||||
{
|
||||
size_t ia, ja;
|
||||
size_t ib;
|
||||
|
||||
for (ia = 0, ja = 0; ia < a->n_apps; ia++) {
|
||||
struct dcb_app *aa = &a->apps[ia];
|
||||
bool present = false;
|
||||
bool found = false;
|
||||
|
||||
for (ib = 0; ib < b->n_apps; ib++) {
|
||||
const struct dcb_app *ab = &b->apps[ib];
|
||||
|
||||
if (aa->selector == ab->selector &&
|
||||
aa->protocol == ab->protocol)
|
||||
present = true;
|
||||
else
|
||||
continue;
|
||||
|
||||
if (aa->priority == ab->priority) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Entries that remain in A will be removed, so keep in the
|
||||
* table only APP entries whose sel/pid is mentioned in B,
|
||||
* but that do not have the full sel/pid/prio match.
|
||||
*/
|
||||
if (present && !found)
|
||||
a->apps[ja++] = *aa;
|
||||
}
|
||||
|
||||
a->n_apps = ja;
|
||||
}
|
||||
|
||||
static int dcb_app_table_copy(struct dcb_app_table *a,
|
||||
const struct dcb_app_table *b)
|
||||
{
|
||||
size_t i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < b->n_apps; i++) {
|
||||
ret = dcb_app_table_push(a, &b->apps[i]);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dcb_app_cmp(const struct dcb_app *a, const struct dcb_app *b)
|
||||
{
|
||||
if (a->protocol < b->protocol)
|
||||
return -1;
|
||||
if (a->protocol > b->protocol)
|
||||
return 1;
|
||||
return a->priority - b->priority;
|
||||
}
|
||||
|
||||
static int dcb_app_cmp_cb(const void *a, const void *b)
|
||||
{
|
||||
return dcb_app_cmp(a, b);
|
||||
}
|
||||
|
||||
static void dcb_app_table_sort(struct dcb_app_table *tab)
|
||||
{
|
||||
qsort(tab->apps, tab->n_apps, sizeof(*tab->apps), dcb_app_cmp_cb);
|
||||
}
|
||||
|
||||
struct dcb_app_parse_mapping {
|
||||
__u8 selector;
|
||||
struct dcb_app_table *tab;
|
||||
int err;
|
||||
};
|
||||
|
||||
static void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data)
|
||||
{
|
||||
struct dcb_app_parse_mapping *pm = data;
|
||||
struct dcb_app app = {
|
||||
.selector = pm->selector,
|
||||
.priority = value,
|
||||
.protocol = key,
|
||||
};
|
||||
|
||||
if (pm->err)
|
||||
return;
|
||||
|
||||
pm->err = dcb_app_table_push(pm->tab, &app);
|
||||
}
|
||||
|
||||
static int dcb_app_parse_mapping_ethtype_prio(__u32 key, char *value, void *data)
|
||||
{
|
||||
__u8 prio;
|
||||
|
||||
if (key < 0x600) {
|
||||
fprintf(stderr, "Protocol IDs < 0x600 are reserved for EtherType\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (get_u8(&prio, value, 0))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_parse_mapping("ETHTYPE", key, 0xffff,
|
||||
"PRIO", prio, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
dcb_app_parse_mapping_cb, data);
|
||||
}
|
||||
|
||||
static int dcb_app_parse_dscp(__u32 *key, const char *arg)
|
||||
{
|
||||
if (parse_mapping_num_all(key, arg) == 0)
|
||||
return 0;
|
||||
|
||||
if (rtnl_dsfield_a2n(key, arg) != 0)
|
||||
return -1;
|
||||
|
||||
if (*key & 0x03) {
|
||||
fprintf(stderr, "The values `%s' uses non-DSCP bits.\n", arg);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Unshift the value to convert it from dsfield to DSCP. */
|
||||
*key >>= 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dcb_app_parse_mapping_dscp_prio(__u32 key, char *value, void *data)
|
||||
{
|
||||
__u8 prio;
|
||||
|
||||
if (get_u8(&prio, value, 0))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_parse_mapping("DSCP", key, 63,
|
||||
"PRIO", prio, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
dcb_app_parse_mapping_cb, data);
|
||||
}
|
||||
|
||||
static int dcb_app_parse_mapping_port_prio(__u32 key, char *value, void *data)
|
||||
{
|
||||
__u8 prio;
|
||||
|
||||
if (key == 0) {
|
||||
fprintf(stderr, "Port ID of 0 is invalid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (get_u8(&prio, value, 0))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_parse_mapping("PORT", key, 0xffff,
|
||||
"PRIO", prio, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
dcb_app_parse_mapping_cb, data);
|
||||
}
|
||||
|
||||
static int dcb_app_parse_default_prio(int *argcp, char ***argvp, struct dcb_app_table *tab)
|
||||
{
|
||||
int argc = *argcp;
|
||||
char **argv = *argvp;
|
||||
int ret = 0;
|
||||
|
||||
while (argc > 0) {
|
||||
struct dcb_app app;
|
||||
__u8 prio;
|
||||
|
||||
if (get_u8(&prio, *argv, 0)) {
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
app = (struct dcb_app){
|
||||
.selector = IEEE_8021QAZ_APP_SEL_ETHERTYPE,
|
||||
.protocol = 0,
|
||||
.priority = prio,
|
||||
};
|
||||
ret = dcb_app_table_push(tab, &app);
|
||||
if (ret != 0)
|
||||
break;
|
||||
|
||||
argc--, argv++;
|
||||
}
|
||||
|
||||
*argcp = argc;
|
||||
*argvp = argv;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool dcb_app_is_ethtype(const struct dcb_app *app)
|
||||
{
|
||||
return app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
|
||||
app->protocol != 0;
|
||||
}
|
||||
|
||||
static bool dcb_app_is_default(const struct dcb_app *app)
|
||||
{
|
||||
return app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
|
||||
app->protocol == 0;
|
||||
}
|
||||
|
||||
static bool dcb_app_is_dscp(const struct dcb_app *app)
|
||||
{
|
||||
return app->selector == IEEE_8021QAZ_APP_SEL_DSCP;
|
||||
}
|
||||
|
||||
static bool dcb_app_is_stream_port(const struct dcb_app *app)
|
||||
{
|
||||
return app->selector == IEEE_8021QAZ_APP_SEL_STREAM;
|
||||
}
|
||||
|
||||
static bool dcb_app_is_dgram_port(const struct dcb_app *app)
|
||||
{
|
||||
return app->selector == IEEE_8021QAZ_APP_SEL_DGRAM;
|
||||
}
|
||||
|
||||
static bool dcb_app_is_port(const struct dcb_app *app)
|
||||
{
|
||||
return app->selector == IEEE_8021QAZ_APP_SEL_ANY;
|
||||
}
|
||||
|
||||
static int dcb_app_print_key_dec(__u16 protocol)
|
||||
{
|
||||
return print_uint(PRINT_ANY, NULL, "%d:", protocol);
|
||||
}
|
||||
|
||||
static int dcb_app_print_key_hex(__u16 protocol)
|
||||
{
|
||||
return print_uint(PRINT_ANY, NULL, "%x:", protocol);
|
||||
}
|
||||
|
||||
static int dcb_app_print_key_dscp(__u16 protocol)
|
||||
{
|
||||
const char *name = rtnl_dsfield_get_name(protocol << 2);
|
||||
|
||||
|
||||
if (!is_json_context() && name != NULL)
|
||||
return print_string(PRINT_FP, NULL, "%s:", name);
|
||||
return print_uint(PRINT_ANY, NULL, "%d:", protocol);
|
||||
}
|
||||
|
||||
static void dcb_app_print_filtered(const struct dcb_app_table *tab,
|
||||
bool (*filter)(const struct dcb_app *),
|
||||
int (*print_key)(__u16 protocol),
|
||||
const char *json_name,
|
||||
const char *fp_name)
|
||||
{
|
||||
bool first = true;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < tab->n_apps; i++) {
|
||||
struct dcb_app *app = &tab->apps[i];
|
||||
|
||||
if (!filter(app))
|
||||
continue;
|
||||
if (first) {
|
||||
open_json_array(PRINT_JSON, json_name);
|
||||
print_string(PRINT_FP, NULL, "%s ", fp_name);
|
||||
first = false;
|
||||
}
|
||||
|
||||
open_json_array(PRINT_JSON, NULL);
|
||||
print_key(app->protocol);
|
||||
print_uint(PRINT_ANY, NULL, "%d ", app->priority);
|
||||
close_json_array(PRINT_JSON, NULL);
|
||||
}
|
||||
|
||||
if (!first) {
|
||||
close_json_array(PRINT_JSON, json_name);
|
||||
print_nl();
|
||||
}
|
||||
}
|
||||
|
||||
static void dcb_app_print_ethtype_prio(const struct dcb_app_table *tab)
|
||||
{
|
||||
dcb_app_print_filtered(tab, dcb_app_is_ethtype, dcb_app_print_key_hex,
|
||||
"ethtype_prio", "ethtype-prio");
|
||||
}
|
||||
|
||||
static void dcb_app_print_dscp_prio(const struct dcb *dcb,
|
||||
const struct dcb_app_table *tab)
|
||||
{
|
||||
dcb_app_print_filtered(tab, dcb_app_is_dscp,
|
||||
dcb->numeric ? dcb_app_print_key_dec
|
||||
: dcb_app_print_key_dscp,
|
||||
"dscp_prio", "dscp-prio");
|
||||
}
|
||||
|
||||
static void dcb_app_print_stream_port_prio(const struct dcb_app_table *tab)
|
||||
{
|
||||
dcb_app_print_filtered(tab, dcb_app_is_stream_port, dcb_app_print_key_dec,
|
||||
"stream_port_prio", "stream-port-prio");
|
||||
}
|
||||
|
||||
static void dcb_app_print_dgram_port_prio(const struct dcb_app_table *tab)
|
||||
{
|
||||
dcb_app_print_filtered(tab, dcb_app_is_dgram_port, dcb_app_print_key_dec,
|
||||
"dgram_port_prio", "dgram-port-prio");
|
||||
}
|
||||
|
||||
static void dcb_app_print_port_prio(const struct dcb_app_table *tab)
|
||||
{
|
||||
dcb_app_print_filtered(tab, dcb_app_is_port, dcb_app_print_key_dec,
|
||||
"port_prio", "port-prio");
|
||||
}
|
||||
|
||||
static void dcb_app_print_default_prio(const struct dcb_app_table *tab)
|
||||
{
|
||||
bool first = true;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < tab->n_apps; i++) {
|
||||
if (!dcb_app_is_default(&tab->apps[i]))
|
||||
continue;
|
||||
if (first) {
|
||||
open_json_array(PRINT_JSON, "default_prio");
|
||||
print_string(PRINT_FP, NULL, "default-prio ", NULL);
|
||||
first = false;
|
||||
}
|
||||
print_uint(PRINT_ANY, NULL, "%d ", tab->apps[i].priority);
|
||||
}
|
||||
|
||||
if (!first) {
|
||||
close_json_array(PRINT_JSON, "default_prio");
|
||||
print_nl();
|
||||
}
|
||||
}
|
||||
|
||||
static void dcb_app_print(const struct dcb *dcb, const struct dcb_app_table *tab)
|
||||
{
|
||||
dcb_app_print_ethtype_prio(tab);
|
||||
dcb_app_print_default_prio(tab);
|
||||
dcb_app_print_dscp_prio(dcb, tab);
|
||||
dcb_app_print_stream_port_prio(tab);
|
||||
dcb_app_print_dgram_port_prio(tab);
|
||||
dcb_app_print_port_prio(tab);
|
||||
}
|
||||
|
||||
static int dcb_app_get_table_attr_cb(const struct nlattr *attr, void *data)
|
||||
{
|
||||
struct dcb_app_table *tab = data;
|
||||
struct dcb_app *app;
|
||||
int ret;
|
||||
|
||||
if (mnl_attr_get_type(attr) != DCB_ATTR_IEEE_APP) {
|
||||
fprintf(stderr, "Unknown attribute in DCB_ATTR_IEEE_APP_TABLE: %d\n",
|
||||
mnl_attr_get_type(attr));
|
||||
return MNL_CB_OK;
|
||||
}
|
||||
if (mnl_attr_get_payload_len(attr) < sizeof(struct dcb_app)) {
|
||||
fprintf(stderr, "DCB_ATTR_IEEE_APP payload expected to have size %zd, not %d\n",
|
||||
sizeof(struct dcb_app), mnl_attr_get_payload_len(attr));
|
||||
return MNL_CB_OK;
|
||||
}
|
||||
|
||||
app = mnl_attr_get_payload(attr);
|
||||
ret = dcb_app_table_push(tab, app);
|
||||
if (ret != 0)
|
||||
return MNL_CB_ERROR;
|
||||
|
||||
return MNL_CB_OK;
|
||||
}
|
||||
|
||||
static int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *tab)
|
||||
{
|
||||
uint16_t payload_len;
|
||||
void *payload;
|
||||
int ret;
|
||||
|
||||
ret = dcb_get_attribute_va(dcb, dev, DCB_ATTR_IEEE_APP_TABLE, &payload, &payload_len);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = mnl_attr_parse_payload(payload, payload_len, dcb_app_get_table_attr_cb, tab);
|
||||
if (ret != MNL_CB_OK)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct dcb_app_add_del {
|
||||
const struct dcb_app_table *tab;
|
||||
bool (*filter)(const struct dcb_app *app);
|
||||
};
|
||||
|
||||
static int dcb_app_add_del_cb(struct dcb *dcb, struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
struct dcb_app_add_del *add_del = data;
|
||||
struct nlattr *nest;
|
||||
size_t i;
|
||||
|
||||
nest = mnl_attr_nest_start(nlh, DCB_ATTR_IEEE_APP_TABLE);
|
||||
|
||||
for (i = 0; i < add_del->tab->n_apps; i++) {
|
||||
const struct dcb_app *app = &add_del->tab->apps[i];
|
||||
|
||||
if (add_del->filter == NULL || add_del->filter(app))
|
||||
mnl_attr_put(nlh, DCB_ATTR_IEEE_APP, sizeof(*app), app);
|
||||
}
|
||||
|
||||
mnl_attr_nest_end(nlh, nest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dcb_app_add_del(struct dcb *dcb, const char *dev, int command,
|
||||
const struct dcb_app_table *tab,
|
||||
bool (*filter)(const struct dcb_app *))
|
||||
{
|
||||
struct dcb_app_add_del add_del = {
|
||||
.tab = tab,
|
||||
.filter = filter,
|
||||
};
|
||||
|
||||
if (tab->n_apps == 0)
|
||||
return 0;
|
||||
|
||||
return dcb_set_attribute_va(dcb, command, dev, dcb_app_add_del_cb, &add_del);
|
||||
}
|
||||
|
||||
static int dcb_cmd_app_parse_add_del(struct dcb *dcb, const char *dev,
|
||||
int argc, char **argv, struct dcb_app_table *tab)
|
||||
{
|
||||
struct dcb_app_parse_mapping pm = {
|
||||
.tab = tab,
|
||||
};
|
||||
int ret;
|
||||
|
||||
if (!argc) {
|
||||
dcb_app_help_add();
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_app_help_add();
|
||||
return 0;
|
||||
} else if (matches(*argv, "ethtype-prio") == 0) {
|
||||
NEXT_ARG();
|
||||
pm.selector = IEEE_8021QAZ_APP_SEL_ETHERTYPE;
|
||||
ret = parse_mapping(&argc, &argv, false,
|
||||
&dcb_app_parse_mapping_ethtype_prio,
|
||||
&pm);
|
||||
} else if (matches(*argv, "default-prio") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = dcb_app_parse_default_prio(&argc, &argv, pm.tab);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Invalid default priority %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
} else if (matches(*argv, "dscp-prio") == 0) {
|
||||
NEXT_ARG();
|
||||
pm.selector = IEEE_8021QAZ_APP_SEL_DSCP;
|
||||
ret = parse_mapping_gen(&argc, &argv,
|
||||
&dcb_app_parse_dscp,
|
||||
&dcb_app_parse_mapping_dscp_prio,
|
||||
&pm);
|
||||
} else if (matches(*argv, "stream-port-prio") == 0) {
|
||||
NEXT_ARG();
|
||||
pm.selector = IEEE_8021QAZ_APP_SEL_STREAM;
|
||||
ret = parse_mapping(&argc, &argv, false,
|
||||
&dcb_app_parse_mapping_port_prio,
|
||||
&pm);
|
||||
} else if (matches(*argv, "dgram-port-prio") == 0) {
|
||||
NEXT_ARG();
|
||||
pm.selector = IEEE_8021QAZ_APP_SEL_DGRAM;
|
||||
ret = parse_mapping(&argc, &argv, false,
|
||||
&dcb_app_parse_mapping_port_prio,
|
||||
&pm);
|
||||
} else if (matches(*argv, "port-prio") == 0) {
|
||||
NEXT_ARG();
|
||||
pm.selector = IEEE_8021QAZ_APP_SEL_ANY;
|
||||
ret = parse_mapping(&argc, &argv, false,
|
||||
&dcb_app_parse_mapping_port_prio,
|
||||
&pm);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_app_help_add();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Invalid mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
if (pm.err)
|
||||
return pm.err;
|
||||
} while (argc > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dcb_cmd_app_add(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct dcb_app_table tab = {};
|
||||
int ret;
|
||||
|
||||
ret = dcb_cmd_app_parse_add_del(dcb, dev, argc, argv, &tab);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_SET, &tab, NULL);
|
||||
dcb_app_table_fini(&tab);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dcb_cmd_app_del(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct dcb_app_table tab = {};
|
||||
int ret;
|
||||
|
||||
ret = dcb_cmd_app_parse_add_del(dcb, dev, argc, argv, &tab);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab, NULL);
|
||||
dcb_app_table_fini(&tab);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dcb_cmd_app_show(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct dcb_app_table tab = {};
|
||||
int ret;
|
||||
|
||||
ret = dcb_app_get(dcb, dev, &tab);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
dcb_app_table_sort(&tab);
|
||||
|
||||
open_json_object(NULL);
|
||||
|
||||
if (!argc) {
|
||||
dcb_app_print(dcb, &tab);
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_app_help_show_flush();
|
||||
goto out;
|
||||
} else if (matches(*argv, "ethtype-prio") == 0) {
|
||||
dcb_app_print_ethtype_prio(&tab);
|
||||
} else if (matches(*argv, "dscp-prio") == 0) {
|
||||
dcb_app_print_dscp_prio(dcb, &tab);
|
||||
} else if (matches(*argv, "stream-port-prio") == 0) {
|
||||
dcb_app_print_stream_port_prio(&tab);
|
||||
} else if (matches(*argv, "dgram-port-prio") == 0) {
|
||||
dcb_app_print_dgram_port_prio(&tab);
|
||||
} else if (matches(*argv, "port-prio") == 0) {
|
||||
dcb_app_print_port_prio(&tab);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_app_help_show_flush();
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
out:
|
||||
close_json_object();
|
||||
dcb_app_table_fini(&tab);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dcb_cmd_app_flush(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct dcb_app_table tab = {};
|
||||
int ret;
|
||||
|
||||
ret = dcb_app_get(dcb, dev, &tab);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
if (!argc) {
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab, NULL);
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_app_help_show_flush();
|
||||
goto out;
|
||||
} else if (matches(*argv, "ethtype-prio") == 0) {
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab,
|
||||
&dcb_app_is_ethtype);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
} else if (matches(*argv, "default-prio") == 0) {
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab,
|
||||
&dcb_app_is_default);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
} else if (matches(*argv, "dscp-prio") == 0) {
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab,
|
||||
&dcb_app_is_dscp);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_app_help_show_flush();
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
out:
|
||||
dcb_app_table_fini(&tab);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dcb_cmd_app_replace(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct dcb_app_table orig = {};
|
||||
struct dcb_app_table tab = {};
|
||||
struct dcb_app_table new = {};
|
||||
int ret;
|
||||
|
||||
ret = dcb_app_get(dcb, dev, &orig);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = dcb_cmd_app_parse_add_del(dcb, dev, argc, argv, &tab);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
|
||||
/* Attempts to add an existing entry would be rejected, so drop
|
||||
* these entries from tab.
|
||||
*/
|
||||
ret = dcb_app_table_copy(&new, &tab);
|
||||
if (ret != 0)
|
||||
goto out;
|
||||
dcb_app_table_remove_existing(&new, &orig);
|
||||
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_SET, &new, NULL);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Could not add new APP entries\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Remove the obsolete entries. */
|
||||
dcb_app_table_remove_replaced(&orig, &tab);
|
||||
ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &orig, NULL);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Could not remove replaced APP entries\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
dcb_app_table_fini(&new);
|
||||
dcb_app_table_fini(&tab);
|
||||
dcb_app_table_fini(&orig);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_cmd_app(struct dcb *dcb, int argc, char **argv)
|
||||
{
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
dcb_app_help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "show") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_app_show, dcb_app_help_show_flush);
|
||||
} else if (matches(*argv, "flush") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_app_flush, dcb_app_help_show_flush);
|
||||
} else if (matches(*argv, "add") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_app_add, dcb_app_help_add);
|
||||
} else if (matches(*argv, "del") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_app_del, dcb_app_help_add);
|
||||
} else if (matches(*argv, "replace") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_app_replace, dcb_app_help_add);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_app_help();
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
235
dcb/dcb_buffer.c
235
dcb/dcb_buffer.c
|
|
@ -1,235 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/dcbnl.h>
|
||||
|
||||
#include "dcb.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void dcb_buffer_help_set(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb buffer set dev STRING\n"
|
||||
" [ prio-buffer PRIO-MAP ]\n"
|
||||
" [ buffer-size SIZE-MAP ]\n"
|
||||
"\n"
|
||||
" where PRIO-MAP := [ PRIO-MAP ] PRIO-MAPPING\n"
|
||||
" PRIO-MAPPING := { all | PRIO }:BUFFER\n"
|
||||
" SIZE-MAP := [ SIZE-MAP ] SIZE-MAPPING\n"
|
||||
" SIZE-MAPPING := { all | BUFFER }:INTEGER\n"
|
||||
" PRIO := { 0 .. 7 }\n"
|
||||
" BUFFER := { 0 .. 7 }\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_buffer_help_show(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb buffer show dev STRING\n"
|
||||
" [ prio-buffer ] [ buffer-size ] [ total-size ]\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_buffer_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb buffer help\n"
|
||||
"\n"
|
||||
);
|
||||
dcb_buffer_help_show();
|
||||
dcb_buffer_help_set();
|
||||
}
|
||||
|
||||
static int dcb_buffer_parse_mapping_prio_buffer(__u32 key, char *value, void *data)
|
||||
{
|
||||
struct dcbnl_buffer *buffer = data;
|
||||
__u8 buf;
|
||||
|
||||
if (get_u8(&buf, value, 0))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_parse_mapping("PRIO", key, IEEE_8021Q_MAX_PRIORITIES - 1,
|
||||
"BUFFER", buf, DCBX_MAX_BUFFERS - 1,
|
||||
dcb_set_u8, buffer->prio2buffer);
|
||||
}
|
||||
|
||||
static int dcb_buffer_parse_mapping_buffer_size(__u32 key, char *value, void *data)
|
||||
{
|
||||
struct dcbnl_buffer *buffer = data;
|
||||
unsigned int size;
|
||||
|
||||
if (get_size(&size, value)) {
|
||||
fprintf(stderr, "%d:%s: Illegal value for buffer size\n", key, value);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return dcb_parse_mapping("BUFFER", key, DCBX_MAX_BUFFERS - 1,
|
||||
"INTEGER", size, -1,
|
||||
dcb_set_u32, buffer->buffer_size);
|
||||
}
|
||||
|
||||
static void dcb_buffer_print_total_size(const struct dcbnl_buffer *buffer)
|
||||
{
|
||||
print_size(PRINT_ANY, "total_size", "total-size %s ", buffer->total_size);
|
||||
}
|
||||
|
||||
static void dcb_buffer_print_prio_buffer(const struct dcbnl_buffer *buffer)
|
||||
{
|
||||
dcb_print_named_array("prio_buffer", "prio-buffer",
|
||||
buffer->prio2buffer, ARRAY_SIZE(buffer->prio2buffer),
|
||||
dcb_print_array_u8);
|
||||
}
|
||||
|
||||
static void dcb_buffer_print_buffer_size(const struct dcbnl_buffer *buffer)
|
||||
{
|
||||
size_t size = ARRAY_SIZE(buffer->buffer_size);
|
||||
SPRINT_BUF(b);
|
||||
size_t i;
|
||||
|
||||
open_json_array(PRINT_JSON, "buffer_size");
|
||||
print_string(PRINT_FP, NULL, "buffer-size ", NULL);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
snprintf(b, sizeof(b), "%zd:%%s ", i);
|
||||
print_size(PRINT_ANY, NULL, b, buffer->buffer_size[i]);
|
||||
}
|
||||
|
||||
close_json_array(PRINT_JSON, "buffer_size");
|
||||
}
|
||||
|
||||
static void dcb_buffer_print(const struct dcbnl_buffer *buffer)
|
||||
{
|
||||
dcb_buffer_print_prio_buffer(buffer);
|
||||
print_nl();
|
||||
|
||||
dcb_buffer_print_buffer_size(buffer);
|
||||
print_nl();
|
||||
|
||||
dcb_buffer_print_total_size(buffer);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
static int dcb_buffer_get(struct dcb *dcb, const char *dev, struct dcbnl_buffer *buffer)
|
||||
{
|
||||
return dcb_get_attribute(dcb, dev, DCB_ATTR_DCB_BUFFER, buffer, sizeof(*buffer));
|
||||
}
|
||||
|
||||
static int dcb_buffer_set(struct dcb *dcb, const char *dev, const struct dcbnl_buffer *buffer)
|
||||
{
|
||||
return dcb_set_attribute(dcb, dev, DCB_ATTR_DCB_BUFFER, buffer, sizeof(*buffer));
|
||||
}
|
||||
|
||||
static int dcb_cmd_buffer_set(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct dcbnl_buffer buffer;
|
||||
int ret;
|
||||
|
||||
if (!argc) {
|
||||
dcb_buffer_help_set();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = dcb_buffer_get(dcb, dev, &buffer);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_buffer_help_set();
|
||||
return 0;
|
||||
} else if (matches(*argv, "prio-buffer") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true,
|
||||
&dcb_buffer_parse_mapping_prio_buffer, &buffer);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid priority mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "buffer-size") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true,
|
||||
&dcb_buffer_parse_mapping_buffer_size, &buffer);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid buffer size mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_buffer_help_set();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
return dcb_buffer_set(dcb, dev, &buffer);
|
||||
}
|
||||
|
||||
static int dcb_cmd_buffer_show(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct dcbnl_buffer buffer;
|
||||
int ret;
|
||||
|
||||
ret = dcb_buffer_get(dcb, dev, &buffer);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
open_json_object(NULL);
|
||||
|
||||
if (!argc) {
|
||||
dcb_buffer_print(&buffer);
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_buffer_help_show();
|
||||
return 0;
|
||||
} else if (matches(*argv, "prio-buffer") == 0) {
|
||||
dcb_buffer_print_prio_buffer(&buffer);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "buffer-size") == 0) {
|
||||
dcb_buffer_print_buffer_size(&buffer);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "total-size") == 0) {
|
||||
dcb_buffer_print_total_size(&buffer);
|
||||
print_nl();
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_buffer_help_show();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
out:
|
||||
close_json_object();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_cmd_buffer(struct dcb *dcb, int argc, char **argv)
|
||||
{
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
dcb_buffer_help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "show") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_buffer_show, dcb_buffer_help_show);
|
||||
} else if (matches(*argv, "set") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_buffer_set, dcb_buffer_help_set);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_buffer_help();
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
192
dcb/dcb_dcbx.c
192
dcb/dcb_dcbx.c
|
|
@ -1,192 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/dcbnl.h>
|
||||
|
||||
#include "dcb.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void dcb_dcbx_help_set(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb dcbx set dev STRING\n"
|
||||
" [ host | lld-managed ]\n"
|
||||
" [ cee | ieee ] [ static ]\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_dcbx_help_show(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb dcbx show dev STRING\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_dcbx_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb dcbx help\n"
|
||||
"\n"
|
||||
);
|
||||
dcb_dcbx_help_show();
|
||||
dcb_dcbx_help_set();
|
||||
}
|
||||
|
||||
struct dcb_dcbx_flag {
|
||||
__u8 value;
|
||||
const char *key_fp;
|
||||
const char *key_json;
|
||||
};
|
||||
|
||||
static struct dcb_dcbx_flag dcb_dcbx_flags[] = {
|
||||
{DCB_CAP_DCBX_HOST, "host"},
|
||||
{DCB_CAP_DCBX_LLD_MANAGED, "lld-managed", "lld_managed"},
|
||||
{DCB_CAP_DCBX_VER_CEE, "cee"},
|
||||
{DCB_CAP_DCBX_VER_IEEE, "ieee"},
|
||||
{DCB_CAP_DCBX_STATIC, "static"},
|
||||
};
|
||||
|
||||
static void dcb_dcbx_print(__u8 dcbx)
|
||||
{
|
||||
int bit;
|
||||
int i;
|
||||
|
||||
while ((bit = ffs(dcbx))) {
|
||||
bool found = false;
|
||||
|
||||
bit--;
|
||||
for (i = 0; i < ARRAY_SIZE(dcb_dcbx_flags); i++) {
|
||||
struct dcb_dcbx_flag *flag = &dcb_dcbx_flags[i];
|
||||
|
||||
if (flag->value == 1 << bit) {
|
||||
print_bool(PRINT_JSON, flag->key_json ?: flag->key_fp,
|
||||
NULL, true);
|
||||
print_string(PRINT_FP, NULL, "%s ", flag->key_fp);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
fprintf(stderr, "Unknown DCBX bit %#x.\n", 1 << bit);
|
||||
|
||||
dcbx &= ~(1 << bit);
|
||||
}
|
||||
|
||||
print_nl();
|
||||
}
|
||||
|
||||
static int dcb_dcbx_get(struct dcb *dcb, const char *dev, __u8 *dcbx)
|
||||
{
|
||||
__u16 payload_len;
|
||||
void *payload;
|
||||
int err;
|
||||
|
||||
err = dcb_get_attribute_bare(dcb, DCB_CMD_IEEE_GET, dev, DCB_ATTR_DCBX,
|
||||
&payload, &payload_len);
|
||||
if (err != 0)
|
||||
return err;
|
||||
|
||||
if (payload_len != 1) {
|
||||
fprintf(stderr, "DCB_ATTR_DCBX payload has size %d, expected 1.\n",
|
||||
payload_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
*dcbx = *(__u8 *) payload;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dcb_dcbx_set(struct dcb *dcb, const char *dev, __u8 dcbx)
|
||||
{
|
||||
return dcb_set_attribute_bare(dcb, DCB_CMD_SDCBX, dev, DCB_ATTR_DCBX,
|
||||
&dcbx, 1, DCB_ATTR_DCBX);
|
||||
}
|
||||
|
||||
static int dcb_cmd_dcbx_set(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
__u8 dcbx = 0;
|
||||
__u8 i;
|
||||
|
||||
if (!argc) {
|
||||
dcb_dcbx_help_set();
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_dcbx_help_set();
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dcb_dcbx_flags); i++) {
|
||||
struct dcb_dcbx_flag *flag = &dcb_dcbx_flags[i];
|
||||
|
||||
if (matches(*argv, flag->key_fp) == 0) {
|
||||
dcbx |= flag->value;
|
||||
NEXT_ARG_FWD();
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_dcbx_help_set();
|
||||
return -EINVAL;
|
||||
|
||||
next:
|
||||
;
|
||||
} while (argc > 0);
|
||||
|
||||
return dcb_dcbx_set(dcb, dev, dcbx);
|
||||
}
|
||||
|
||||
static int dcb_cmd_dcbx_show(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
__u8 dcbx;
|
||||
int ret;
|
||||
|
||||
ret = dcb_dcbx_get(dcb, dev, &dcbx);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
while (argc > 0) {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_dcbx_help_show();
|
||||
return 0;
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_dcbx_help_show();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
}
|
||||
|
||||
open_json_object(NULL);
|
||||
dcb_dcbx_print(dcbx);
|
||||
close_json_object();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_cmd_dcbx(struct dcb *dcb, int argc, char **argv)
|
||||
{
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
dcb_dcbx_help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "show") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_dcbx_show, dcb_dcbx_help_show);
|
||||
} else if (matches(*argv, "set") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_dcbx_set, dcb_dcbx_help_set);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_dcbx_help();
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
435
dcb/dcb_ets.c
435
dcb/dcb_ets.c
|
|
@ -1,435 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/dcbnl.h>
|
||||
|
||||
#include "dcb.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void dcb_ets_help_set(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb ets set dev STRING\n"
|
||||
" [ willing { on | off } ]\n"
|
||||
" [ { tc-tsa | reco-tc-tsa } TSA-MAP ]\n"
|
||||
" [ { pg-bw | tc-bw | reco-tc-bw } BW-MAP ]\n"
|
||||
" [ { prio-tc | reco-prio-tc } PRIO-MAP ]\n"
|
||||
"\n"
|
||||
" where TSA-MAP := [ TSA-MAP ] TSA-MAPPING\n"
|
||||
" TSA-MAPPING := { all | TC }:{ strict | cbs | ets | vendor }\n"
|
||||
" BW-MAP := [ BW-MAP ] BW-MAPPING\n"
|
||||
" BW-MAPPING := { all | TC }:INTEGER\n"
|
||||
" PRIO-MAP := [ PRIO-MAP ] PRIO-MAPPING\n"
|
||||
" PRIO-MAPPING := { all | PRIO }:TC\n"
|
||||
" TC := { 0 .. 7 }\n"
|
||||
" PRIO := { 0 .. 7 }\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_ets_help_show(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb ets show dev STRING\n"
|
||||
" [ willing ] [ ets-cap ] [ cbs ] [ tc-tsa ]\n"
|
||||
" [ reco-tc-tsa ] [ pg-bw ] [ tc-bw ] [ reco-tc-bw ]\n"
|
||||
" [ prio-tc ] [ reco-prio-tc ]\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_ets_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb ets help\n"
|
||||
"\n"
|
||||
);
|
||||
dcb_ets_help_show();
|
||||
dcb_ets_help_set();
|
||||
}
|
||||
|
||||
static const char *const tsa_names[] = {
|
||||
[IEEE_8021QAZ_TSA_STRICT] = "strict",
|
||||
[IEEE_8021QAZ_TSA_CB_SHAPER] = "cbs",
|
||||
[IEEE_8021QAZ_TSA_ETS] = "ets",
|
||||
[IEEE_8021QAZ_TSA_VENDOR] = "vendor",
|
||||
};
|
||||
|
||||
static int dcb_ets_parse_mapping_tc_tsa(__u32 key, char *value, void *data)
|
||||
{
|
||||
__u8 tsa;
|
||||
int ret;
|
||||
|
||||
tsa = parse_one_of("TSA", value, tsa_names, ARRAY_SIZE(tsa_names), &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return dcb_parse_mapping("TC", key, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
"TSA", tsa, -1U,
|
||||
dcb_set_u8, data);
|
||||
}
|
||||
|
||||
static int dcb_ets_parse_mapping_tc_bw(__u32 key, char *value, void *data)
|
||||
{
|
||||
__u8 bw;
|
||||
|
||||
if (get_u8(&bw, value, 0))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_parse_mapping("TC", key, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
"BW", bw, 100,
|
||||
dcb_set_u8, data);
|
||||
}
|
||||
|
||||
static int dcb_ets_parse_mapping_prio_tc(unsigned int key, char *value, void *data)
|
||||
{
|
||||
__u8 tc;
|
||||
|
||||
if (get_u8(&tc, value, 0))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_parse_mapping("PRIO", key, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
"TC", tc, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
dcb_set_u8, data);
|
||||
}
|
||||
|
||||
static void dcb_print_array_tsa(const __u8 *array, size_t size)
|
||||
{
|
||||
dcb_print_array_kw(array, size, tsa_names, ARRAY_SIZE(tsa_names));
|
||||
}
|
||||
|
||||
static void dcb_ets_print_willing(const struct ieee_ets *ets)
|
||||
{
|
||||
print_on_off(PRINT_ANY, "willing", "willing %s ", ets->willing);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_ets_cap(const struct ieee_ets *ets)
|
||||
{
|
||||
print_uint(PRINT_ANY, "ets_cap", "ets-cap %d ", ets->ets_cap);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_cbs(const struct ieee_ets *ets)
|
||||
{
|
||||
print_on_off(PRINT_ANY, "cbs", "cbs %s ", ets->cbs);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_tc_bw(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_print_named_array("tc_bw", "tc-bw",
|
||||
ets->tc_tx_bw, ARRAY_SIZE(ets->tc_tx_bw),
|
||||
dcb_print_array_u8);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_pg_bw(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_print_named_array("pg_bw", "pg-bw",
|
||||
ets->tc_rx_bw, ARRAY_SIZE(ets->tc_rx_bw),
|
||||
dcb_print_array_u8);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_tc_tsa(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_print_named_array("tc_tsa", "tc-tsa",
|
||||
ets->tc_tsa, ARRAY_SIZE(ets->tc_tsa),
|
||||
dcb_print_array_tsa);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_prio_tc(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_print_named_array("prio_tc", "prio-tc",
|
||||
ets->prio_tc, ARRAY_SIZE(ets->prio_tc),
|
||||
dcb_print_array_u8);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_reco_tc_bw(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_print_named_array("reco_tc_bw", "reco-tc-bw",
|
||||
ets->tc_reco_bw, ARRAY_SIZE(ets->tc_reco_bw),
|
||||
dcb_print_array_u8);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_reco_tc_tsa(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_print_named_array("reco_tc_tsa", "reco-tc-tsa",
|
||||
ets->tc_reco_tsa, ARRAY_SIZE(ets->tc_reco_tsa),
|
||||
dcb_print_array_tsa);
|
||||
}
|
||||
|
||||
static void dcb_ets_print_reco_prio_tc(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_print_named_array("reco_prio_tc", "reco-prio-tc",
|
||||
ets->reco_prio_tc, ARRAY_SIZE(ets->reco_prio_tc),
|
||||
dcb_print_array_u8);
|
||||
}
|
||||
|
||||
static void dcb_ets_print(const struct ieee_ets *ets)
|
||||
{
|
||||
dcb_ets_print_willing(ets);
|
||||
dcb_ets_print_ets_cap(ets);
|
||||
dcb_ets_print_cbs(ets);
|
||||
print_nl();
|
||||
|
||||
dcb_ets_print_tc_bw(ets);
|
||||
print_nl();
|
||||
|
||||
dcb_ets_print_pg_bw(ets);
|
||||
print_nl();
|
||||
|
||||
dcb_ets_print_tc_tsa(ets);
|
||||
print_nl();
|
||||
|
||||
dcb_ets_print_prio_tc(ets);
|
||||
print_nl();
|
||||
|
||||
dcb_ets_print_reco_tc_bw(ets);
|
||||
print_nl();
|
||||
|
||||
dcb_ets_print_reco_tc_tsa(ets);
|
||||
print_nl();
|
||||
|
||||
dcb_ets_print_reco_prio_tc(ets);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
static int dcb_ets_get(struct dcb *dcb, const char *dev, struct ieee_ets *ets)
|
||||
{
|
||||
return dcb_get_attribute(dcb, dev, DCB_ATTR_IEEE_ETS, ets, sizeof(*ets));
|
||||
}
|
||||
|
||||
static int dcb_ets_validate_bw(const __u8 bw[], const __u8 tsa[], const char *what)
|
||||
{
|
||||
bool has_ets = false;
|
||||
unsigned int total = 0;
|
||||
unsigned int tc;
|
||||
|
||||
for (tc = 0; tc < IEEE_8021QAZ_MAX_TCS; tc++) {
|
||||
if (tsa[tc] == IEEE_8021QAZ_TSA_ETS) {
|
||||
has_ets = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* TC bandwidth is only intended for ETS, but 802.1Q-2018 only requires
|
||||
* that the sum be 100, and individual entries 0..100. It explicitly
|
||||
* notes that non-ETS TCs can have non-0 TC bandwidth during
|
||||
* reconfiguration.
|
||||
*/
|
||||
for (tc = 0; tc < IEEE_8021QAZ_MAX_TCS; tc++) {
|
||||
if (bw[tc] > 100) {
|
||||
fprintf(stderr, "%d%% for TC %d of %s is not a valid bandwidth percentage, expected 0..100%%\n",
|
||||
bw[tc], tc, what);
|
||||
return -EINVAL;
|
||||
}
|
||||
total += bw[tc];
|
||||
}
|
||||
|
||||
/* This is what 802.1Q-2018 requires. */
|
||||
if (total == 100)
|
||||
return 0;
|
||||
|
||||
/* But this requirement does not make sense for all-strict
|
||||
* configurations. Anything else than 0 does not make sense: either BW
|
||||
* has not been reconfigured for the all-strict allocation yet, at which
|
||||
* point we expect sum of 100. Or it has already been reconfigured, at
|
||||
* which point accept 0.
|
||||
*/
|
||||
if (!has_ets && total == 0)
|
||||
return 0;
|
||||
|
||||
fprintf(stderr, "Bandwidth percentages in %s sum to %d%%, expected %d%%\n",
|
||||
what, total, has_ets ? 100 : 0);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int dcb_ets_set(struct dcb *dcb, const char *dev, const struct ieee_ets *ets)
|
||||
{
|
||||
/* Do not validate pg-bw, which is not standard and has unclear
|
||||
* meaning.
|
||||
*/
|
||||
if (dcb_ets_validate_bw(ets->tc_tx_bw, ets->tc_tsa, "tc-bw") ||
|
||||
dcb_ets_validate_bw(ets->tc_reco_bw, ets->tc_reco_tsa, "reco-tc-bw"))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_set_attribute(dcb, dev, DCB_ATTR_IEEE_ETS, ets, sizeof(*ets));
|
||||
}
|
||||
|
||||
static int dcb_cmd_ets_set(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct ieee_ets ets;
|
||||
int ret;
|
||||
|
||||
if (!argc) {
|
||||
dcb_ets_help_set();
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = dcb_ets_get(dcb, dev, &ets);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_ets_help_set();
|
||||
return 0;
|
||||
} else if (matches(*argv, "willing") == 0) {
|
||||
NEXT_ARG();
|
||||
ets.willing = parse_on_off("willing", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else if (matches(*argv, "tc-tsa") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true, &dcb_ets_parse_mapping_tc_tsa,
|
||||
ets.tc_tsa);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid tc-tsa mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "reco-tc-tsa") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true, &dcb_ets_parse_mapping_tc_tsa,
|
||||
ets.tc_reco_tsa);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid reco-tc-tsa mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "tc-bw") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true, &dcb_ets_parse_mapping_tc_bw,
|
||||
ets.tc_tx_bw);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid tc-bw mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "pg-bw") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true, &dcb_ets_parse_mapping_tc_bw,
|
||||
ets.tc_rx_bw);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid pg-bw mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "reco-tc-bw") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true, &dcb_ets_parse_mapping_tc_bw,
|
||||
ets.tc_reco_bw);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid reco-tc-bw mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "prio-tc") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true, &dcb_ets_parse_mapping_prio_tc,
|
||||
ets.prio_tc);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid prio-tc mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "reco-prio-tc") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true, &dcb_ets_parse_mapping_prio_tc,
|
||||
ets.reco_prio_tc);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid reco-prio-tc mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_ets_help_set();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
return dcb_ets_set(dcb, dev, &ets);
|
||||
}
|
||||
|
||||
static int dcb_cmd_ets_show(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct ieee_ets ets;
|
||||
int ret;
|
||||
|
||||
ret = dcb_ets_get(dcb, dev, &ets);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
open_json_object(NULL);
|
||||
|
||||
if (!argc) {
|
||||
dcb_ets_print(&ets);
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_ets_help_show();
|
||||
return 0;
|
||||
} else if (matches(*argv, "willing") == 0) {
|
||||
dcb_ets_print_willing(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "ets-cap") == 0) {
|
||||
dcb_ets_print_ets_cap(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "cbs") == 0) {
|
||||
dcb_ets_print_cbs(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "tc-tsa") == 0) {
|
||||
dcb_ets_print_tc_tsa(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "reco-tc-tsa") == 0) {
|
||||
dcb_ets_print_reco_tc_tsa(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "tc-bw") == 0) {
|
||||
dcb_ets_print_tc_bw(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "pg-bw") == 0) {
|
||||
dcb_ets_print_pg_bw(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "reco-tc-bw") == 0) {
|
||||
dcb_ets_print_reco_tc_bw(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "prio-tc") == 0) {
|
||||
dcb_ets_print_prio_tc(&ets);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "reco-prio-tc") == 0) {
|
||||
dcb_ets_print_reco_prio_tc(&ets);
|
||||
print_nl();
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_ets_help_show();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
out:
|
||||
close_json_object();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_cmd_ets(struct dcb *dcb, int argc, char **argv)
|
||||
{
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
dcb_ets_help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "show") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv, dcb_cmd_ets_show, dcb_ets_help_show);
|
||||
} else if (matches(*argv, "set") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv, dcb_cmd_ets_set, dcb_ets_help_set);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_ets_help();
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/dcbnl.h>
|
||||
|
||||
#include "dcb.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void dcb_maxrate_help_set(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb maxrate set dev STRING\n"
|
||||
" [ tc-maxrate RATE-MAP ]\n"
|
||||
"\n"
|
||||
" where RATE-MAP := [ RATE-MAP ] RATE-MAPPING\n"
|
||||
" RATE-MAPPING := { all | TC }:RATE\n"
|
||||
" TC := { 0 .. 7 }\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_maxrate_help_show(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb [ -i ] maxrate show dev STRING\n"
|
||||
" [ tc-maxrate ]\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_maxrate_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb maxrate help\n"
|
||||
"\n"
|
||||
);
|
||||
dcb_maxrate_help_show();
|
||||
dcb_maxrate_help_set();
|
||||
}
|
||||
|
||||
static int dcb_maxrate_parse_mapping_tc_maxrate(__u32 key, char *value, void *data)
|
||||
{
|
||||
__u64 rate;
|
||||
|
||||
if (get_rate64(&rate, value))
|
||||
return -EINVAL;
|
||||
|
||||
return dcb_parse_mapping("TC", key, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
"RATE", rate, -1,
|
||||
dcb_set_u64, data);
|
||||
}
|
||||
|
||||
static void dcb_maxrate_print_tc_maxrate(struct dcb *dcb, const struct ieee_maxrate *maxrate)
|
||||
{
|
||||
size_t size = ARRAY_SIZE(maxrate->tc_maxrate);
|
||||
SPRINT_BUF(b);
|
||||
size_t i;
|
||||
|
||||
open_json_array(PRINT_JSON, "tc_maxrate");
|
||||
print_string(PRINT_FP, NULL, "tc-maxrate ", NULL);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
snprintf(b, sizeof(b), "%zd:%%s ", i);
|
||||
print_rate(dcb->use_iec, PRINT_ANY, NULL, b, maxrate->tc_maxrate[i]);
|
||||
}
|
||||
|
||||
close_json_array(PRINT_JSON, "tc_maxrate");
|
||||
}
|
||||
|
||||
static void dcb_maxrate_print(struct dcb *dcb, const struct ieee_maxrate *maxrate)
|
||||
{
|
||||
dcb_maxrate_print_tc_maxrate(dcb, maxrate);
|
||||
print_nl();
|
||||
}
|
||||
|
||||
static int dcb_maxrate_get(struct dcb *dcb, const char *dev, struct ieee_maxrate *maxrate)
|
||||
{
|
||||
return dcb_get_attribute(dcb, dev, DCB_ATTR_IEEE_MAXRATE, maxrate, sizeof(*maxrate));
|
||||
}
|
||||
|
||||
static int dcb_maxrate_set(struct dcb *dcb, const char *dev, const struct ieee_maxrate *maxrate)
|
||||
{
|
||||
return dcb_set_attribute(dcb, dev, DCB_ATTR_IEEE_MAXRATE, maxrate, sizeof(*maxrate));
|
||||
}
|
||||
|
||||
static int dcb_cmd_maxrate_set(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct ieee_maxrate maxrate;
|
||||
int ret;
|
||||
|
||||
if (!argc) {
|
||||
dcb_maxrate_help_set();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = dcb_maxrate_get(dcb, dev, &maxrate);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_maxrate_help_set();
|
||||
return 0;
|
||||
} else if (matches(*argv, "tc-maxrate") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true,
|
||||
&dcb_maxrate_parse_mapping_tc_maxrate, &maxrate);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_maxrate_help_set();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
return dcb_maxrate_set(dcb, dev, &maxrate);
|
||||
}
|
||||
|
||||
static int dcb_cmd_maxrate_show(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct ieee_maxrate maxrate;
|
||||
int ret;
|
||||
|
||||
ret = dcb_maxrate_get(dcb, dev, &maxrate);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
open_json_object(NULL);
|
||||
|
||||
if (!argc) {
|
||||
dcb_maxrate_print(dcb, &maxrate);
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_maxrate_help_show();
|
||||
return 0;
|
||||
} else if (matches(*argv, "tc-maxrate") == 0) {
|
||||
dcb_maxrate_print_tc_maxrate(dcb, &maxrate);
|
||||
print_nl();
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_maxrate_help_show();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
out:
|
||||
close_json_object();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_cmd_maxrate(struct dcb *dcb, int argc, char **argv)
|
||||
{
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
dcb_maxrate_help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "show") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_maxrate_show, dcb_maxrate_help_show);
|
||||
} else if (matches(*argv, "set") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_maxrate_set, dcb_maxrate_help_set);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_maxrate_help();
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
286
dcb/dcb_pfc.c
286
dcb/dcb_pfc.c
|
|
@ -1,286 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/dcbnl.h>
|
||||
|
||||
#include "dcb.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void dcb_pfc_help_set(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb pfc set dev STRING\n"
|
||||
" [ prio-pfc PFC-MAP ]\n"
|
||||
" [ macsec-bypass { on | off } ]\n"
|
||||
" [ delay INTEGER ]\n"
|
||||
"\n"
|
||||
" where PFC-MAP := [ PFC-MAP ] PFC-MAPPING\n"
|
||||
" PFC-MAPPING := { all | TC }:PFC\n"
|
||||
" TC := { 0 .. 7 }\n"
|
||||
" PFC := { on | off }\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_pfc_help_show(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb [ -s ] pfc show dev STRING\n"
|
||||
" [ pfc-cap ] [ prio-pfc ] [ macsec-bypass ]\n"
|
||||
" [ delay ] [ requests ] [ indications ]\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void dcb_pfc_help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: dcb pfc help\n"
|
||||
"\n"
|
||||
);
|
||||
dcb_pfc_help_show();
|
||||
dcb_pfc_help_set();
|
||||
}
|
||||
|
||||
static void dcb_pfc_to_array(__u8 array[IEEE_8021QAZ_MAX_TCS], __u8 pfc_en)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
|
||||
array[i] = !!(pfc_en & (1 << i));
|
||||
}
|
||||
|
||||
static void dcb_pfc_from_array(__u8 array[IEEE_8021QAZ_MAX_TCS], __u8 *pfc_en_p)
|
||||
{
|
||||
__u8 pfc_en = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
|
||||
if (array[i])
|
||||
pfc_en |= 1 << i;
|
||||
}
|
||||
|
||||
*pfc_en_p = pfc_en;
|
||||
}
|
||||
|
||||
static int dcb_pfc_parse_mapping_prio_pfc(__u32 key, char *value, void *data)
|
||||
{
|
||||
struct ieee_pfc *pfc = data;
|
||||
__u8 pfc_en[IEEE_8021QAZ_MAX_TCS];
|
||||
bool enabled;
|
||||
int ret;
|
||||
|
||||
dcb_pfc_to_array(pfc_en, pfc->pfc_en);
|
||||
|
||||
enabled = parse_on_off("PFC", value, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = dcb_parse_mapping("PRIO", key, IEEE_8021QAZ_MAX_TCS - 1,
|
||||
"PFC", enabled, -1,
|
||||
dcb_set_u8, pfc_en);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
dcb_pfc_from_array(pfc_en, &pfc->pfc_en);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dcb_pfc_print_pfc_cap(const struct ieee_pfc *pfc)
|
||||
{
|
||||
print_uint(PRINT_ANY, "pfc_cap", "pfc-cap %d ", pfc->pfc_cap);
|
||||
}
|
||||
|
||||
static void dcb_pfc_print_macsec_bypass(const struct ieee_pfc *pfc)
|
||||
{
|
||||
print_on_off(PRINT_ANY, "macsec_bypass", "macsec-bypass %s ", pfc->mbc);
|
||||
}
|
||||
|
||||
static void dcb_pfc_print_delay(const struct ieee_pfc *pfc)
|
||||
{
|
||||
print_uint(PRINT_ANY, "delay", "delay %d ", pfc->delay);
|
||||
}
|
||||
|
||||
static void dcb_pfc_print_prio_pfc(const struct ieee_pfc *pfc)
|
||||
{
|
||||
__u8 pfc_en[IEEE_8021QAZ_MAX_TCS];
|
||||
|
||||
dcb_pfc_to_array(pfc_en, pfc->pfc_en);
|
||||
dcb_print_named_array("prio_pfc", "prio-pfc",
|
||||
pfc_en, ARRAY_SIZE(pfc_en), &dcb_print_array_on_off);
|
||||
}
|
||||
|
||||
static void dcb_pfc_print_requests(const struct ieee_pfc *pfc)
|
||||
{
|
||||
open_json_array(PRINT_JSON, "requests");
|
||||
print_string(PRINT_FP, NULL, "requests ", NULL);
|
||||
dcb_print_array_u64(pfc->requests, ARRAY_SIZE(pfc->requests));
|
||||
close_json_array(PRINT_JSON, "requests");
|
||||
}
|
||||
|
||||
static void dcb_pfc_print_indications(const struct ieee_pfc *pfc)
|
||||
{
|
||||
open_json_array(PRINT_JSON, "indications");
|
||||
print_string(PRINT_FP, NULL, "indications ", NULL);
|
||||
dcb_print_array_u64(pfc->indications, ARRAY_SIZE(pfc->indications));
|
||||
close_json_array(PRINT_JSON, "indications");
|
||||
}
|
||||
|
||||
static void dcb_pfc_print(const struct dcb *dcb, const struct ieee_pfc *pfc)
|
||||
{
|
||||
dcb_pfc_print_pfc_cap(pfc);
|
||||
dcb_pfc_print_macsec_bypass(pfc);
|
||||
dcb_pfc_print_delay(pfc);
|
||||
print_nl();
|
||||
|
||||
dcb_pfc_print_prio_pfc(pfc);
|
||||
print_nl();
|
||||
|
||||
if (dcb->stats) {
|
||||
dcb_pfc_print_requests(pfc);
|
||||
print_nl();
|
||||
|
||||
dcb_pfc_print_indications(pfc);
|
||||
print_nl();
|
||||
}
|
||||
}
|
||||
|
||||
static int dcb_pfc_get(struct dcb *dcb, const char *dev, struct ieee_pfc *pfc)
|
||||
{
|
||||
return dcb_get_attribute(dcb, dev, DCB_ATTR_IEEE_PFC, pfc, sizeof(*pfc));
|
||||
}
|
||||
|
||||
static int dcb_pfc_set(struct dcb *dcb, const char *dev, const struct ieee_pfc *pfc)
|
||||
{
|
||||
return dcb_set_attribute(dcb, dev, DCB_ATTR_IEEE_PFC, pfc, sizeof(*pfc));
|
||||
}
|
||||
|
||||
static int dcb_cmd_pfc_set(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct ieee_pfc pfc;
|
||||
int ret;
|
||||
|
||||
if (!argc) {
|
||||
dcb_pfc_help_set();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = dcb_pfc_get(dcb, dev, &pfc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_pfc_help_set();
|
||||
return 0;
|
||||
} else if (matches(*argv, "prio-pfc") == 0) {
|
||||
NEXT_ARG();
|
||||
ret = parse_mapping(&argc, &argv, true,
|
||||
&dcb_pfc_parse_mapping_prio_pfc, &pfc);
|
||||
if (ret) {
|
||||
fprintf(stderr, "Invalid pfc mapping %s\n", *argv);
|
||||
return ret;
|
||||
}
|
||||
continue;
|
||||
} else if (matches(*argv, "macsec-bypass") == 0) {
|
||||
NEXT_ARG();
|
||||
pfc.mbc = parse_on_off("macsec-bypass", *argv, &ret);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else if (matches(*argv, "delay") == 0) {
|
||||
NEXT_ARG();
|
||||
/* Do not support the size notations for delay.
|
||||
* Delay is specified in "bit times", not bits, so
|
||||
* it is not applicable. At the same time it would
|
||||
* be confusing that 10Kbit does not mean 10240,
|
||||
* but 1280.
|
||||
*/
|
||||
if (get_u16(&pfc.delay, *argv, 0)) {
|
||||
fprintf(stderr, "Invalid delay `%s', expected an integer 0..65535\n",
|
||||
*argv);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_pfc_help_set();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
return dcb_pfc_set(dcb, dev, &pfc);
|
||||
}
|
||||
|
||||
static int dcb_cmd_pfc_show(struct dcb *dcb, const char *dev, int argc, char **argv)
|
||||
{
|
||||
struct ieee_pfc pfc;
|
||||
int ret;
|
||||
|
||||
ret = dcb_pfc_get(dcb, dev, &pfc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
open_json_object(NULL);
|
||||
|
||||
if (!argc) {
|
||||
dcb_pfc_print(dcb, &pfc);
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches(*argv, "help") == 0) {
|
||||
dcb_pfc_help_show();
|
||||
return 0;
|
||||
} else if (matches(*argv, "prio-pfc") == 0) {
|
||||
dcb_pfc_print_prio_pfc(&pfc);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "pfc-cap") == 0) {
|
||||
dcb_pfc_print_pfc_cap(&pfc);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "macsec-bypass") == 0) {
|
||||
dcb_pfc_print_macsec_bypass(&pfc);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "delay") == 0) {
|
||||
dcb_pfc_print_delay(&pfc);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "requests") == 0) {
|
||||
dcb_pfc_print_requests(&pfc);
|
||||
print_nl();
|
||||
} else if (matches(*argv, "indications") == 0) {
|
||||
dcb_pfc_print_indications(&pfc);
|
||||
print_nl();
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_pfc_help_show();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
NEXT_ARG_FWD();
|
||||
} while (argc > 0);
|
||||
|
||||
out:
|
||||
close_json_object();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dcb_cmd_pfc(struct dcb *dcb, int argc, char **argv)
|
||||
{
|
||||
if (!argc || matches(*argv, "help") == 0) {
|
||||
dcb_pfc_help();
|
||||
return 0;
|
||||
} else if (matches(*argv, "show") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_pfc_show, dcb_pfc_help_show);
|
||||
} else if (matches(*argv, "set") == 0) {
|
||||
NEXT_ARG_FWD();
|
||||
return dcb_cmd_parse_dev(dcb, argc, argv,
|
||||
dcb_cmd_pfc_set, dcb_pfc_help_set);
|
||||
} else {
|
||||
fprintf(stderr, "What is \"%s\"?\n", *argv);
|
||||
dcb_pfc_help();
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,13 +7,12 @@ ifeq ($(HAVE_MNL),y)
|
|||
|
||||
DEVLINKOBJ = devlink.o mnlg.o
|
||||
TARGETS += devlink
|
||||
LDLIBS += -lm
|
||||
|
||||
endif
|
||||
|
||||
all: $(TARGETS) $(LIBS)
|
||||
|
||||
devlink: $(DEVLINKOBJ) $(LIBNETLINK)
|
||||
devlink: $(DEVLINKOBJ)
|
||||
$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||
|
||||
install: all
|
||||
|
|
|
|||
2458
devlink/devlink.c
2458
devlink/devlink.c
File diff suppressed because it is too large
Load Diff
192
devlink/mnlg.c
192
devlink/mnlg.c
|
|
@ -14,11 +14,11 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <libmnl/libmnl.h>
|
||||
#include <linux/genetlink.h>
|
||||
|
||||
#include "libnetlink.h"
|
||||
#include "mnl_utils.h"
|
||||
#include "utils.h"
|
||||
#include "mnlg.h"
|
||||
|
||||
|
|
@ -28,13 +28,97 @@ struct mnlg_socket {
|
|||
uint32_t id;
|
||||
uint8_t version;
|
||||
unsigned int seq;
|
||||
unsigned int portid;
|
||||
};
|
||||
|
||||
int mnlg_socket_send(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh)
|
||||
static struct nlmsghdr *__mnlg_msg_prepare(struct mnlg_socket *nlg, uint8_t cmd,
|
||||
uint16_t flags, uint32_t id,
|
||||
uint8_t version)
|
||||
{
|
||||
struct nlmsghdr *nlh;
|
||||
struct genlmsghdr *genl;
|
||||
|
||||
nlh = mnl_nlmsg_put_header(nlg->buf);
|
||||
nlh->nlmsg_type = id;
|
||||
nlh->nlmsg_flags = flags;
|
||||
nlg->seq = time(NULL);
|
||||
nlh->nlmsg_seq = nlg->seq;
|
||||
|
||||
genl = mnl_nlmsg_put_extra_header(nlh, sizeof(struct genlmsghdr));
|
||||
genl->cmd = cmd;
|
||||
genl->version = version;
|
||||
|
||||
return nlh;
|
||||
}
|
||||
|
||||
struct nlmsghdr *mnlg_msg_prepare(struct mnlg_socket *nlg, uint8_t cmd,
|
||||
uint16_t flags)
|
||||
{
|
||||
return __mnlg_msg_prepare(nlg, cmd, flags, nlg->id, nlg->version);
|
||||
}
|
||||
|
||||
int mnlg_socket_send(struct mnlg_socket *nlg, const struct nlmsghdr *nlh)
|
||||
{
|
||||
return mnl_socket_sendto(nlg->nl, nlh, nlh->nlmsg_len);
|
||||
}
|
||||
|
||||
static int mnlg_cb_noop(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
return MNL_CB_OK;
|
||||
}
|
||||
|
||||
static int mnlg_cb_error(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
const struct nlmsgerr *err = mnl_nlmsg_get_payload(nlh);
|
||||
|
||||
/* Netlink subsystems returns the errno value with different signess */
|
||||
if (err->error < 0)
|
||||
errno = -err->error;
|
||||
else
|
||||
errno = err->error;
|
||||
|
||||
if (nl_dump_ext_ack(nlh, NULL))
|
||||
return MNL_CB_ERROR;
|
||||
|
||||
return err->error == 0 ? MNL_CB_STOP : MNL_CB_ERROR;
|
||||
}
|
||||
|
||||
static int mnlg_cb_stop(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
int len = *(int *)NLMSG_DATA(nlh);
|
||||
|
||||
if (len < 0) {
|
||||
errno = -len;
|
||||
nl_dump_ext_ack_done(nlh, len);
|
||||
return MNL_CB_ERROR;
|
||||
}
|
||||
return MNL_CB_STOP;
|
||||
}
|
||||
|
||||
static mnl_cb_t mnlg_cb_array[NLMSG_MIN_TYPE] = {
|
||||
[NLMSG_NOOP] = mnlg_cb_noop,
|
||||
[NLMSG_ERROR] = mnlg_cb_error,
|
||||
[NLMSG_DONE] = mnlg_cb_stop,
|
||||
[NLMSG_OVERRUN] = mnlg_cb_noop,
|
||||
};
|
||||
|
||||
int mnlg_socket_recv_run(struct mnlg_socket *nlg, mnl_cb_t data_cb, void *data)
|
||||
{
|
||||
int err;
|
||||
|
||||
do {
|
||||
err = mnl_socket_recvfrom(nlg->nl, nlg->buf,
|
||||
MNL_SOCKET_BUFFER_SIZE);
|
||||
if (err <= 0)
|
||||
break;
|
||||
err = mnl_cb_run2(nlg->buf, err, nlg->seq, nlg->portid,
|
||||
data_cb, data, mnlg_cb_array,
|
||||
ARRAY_SIZE(mnlg_cb_array));
|
||||
} while (err > 0);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
struct group_info {
|
||||
bool found;
|
||||
uint32_t id;
|
||||
|
|
@ -114,17 +198,15 @@ static int get_group_id_cb(const struct nlmsghdr *nlh, void *data)
|
|||
return MNL_CB_OK;
|
||||
}
|
||||
|
||||
int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name)
|
||||
int mnlg_socket_group_add(struct mnlg_socket *nlg, const char *group_name)
|
||||
{
|
||||
struct nlmsghdr *nlh;
|
||||
struct group_info group_info;
|
||||
int err;
|
||||
|
||||
nlh = _mnlu_gen_socket_cmd_prepare(nlg, CTRL_CMD_GETFAMILY,
|
||||
NLM_F_REQUEST | NLM_F_ACK,
|
||||
GENL_ID_CTRL, 1);
|
||||
|
||||
mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, nlg->family);
|
||||
nlh = __mnlg_msg_prepare(nlg, CTRL_CMD_GETFAMILY,
|
||||
NLM_F_REQUEST | NLM_F_ACK, GENL_ID_CTRL, 1);
|
||||
mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, nlg->id);
|
||||
|
||||
err = mnlg_socket_send(nlg, nlh);
|
||||
if (err < 0)
|
||||
|
|
@ -132,7 +214,7 @@ int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name)
|
|||
|
||||
group_info.found = false;
|
||||
group_info.name = group_name;
|
||||
err = mnlu_gen_socket_recv_run(nlg, get_group_id_cb, &group_info);
|
||||
err = mnlg_socket_recv_run(nlg, get_group_id_cb, &group_info);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
|
|
@ -149,7 +231,97 @@ int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mnlg_socket_get_fd(struct mnlu_gen_socket *nlg)
|
||||
static int get_family_id_attr_cb(const struct nlattr *attr, void *data)
|
||||
{
|
||||
const struct nlattr **tb = data;
|
||||
int type = mnl_attr_get_type(attr);
|
||||
|
||||
if (mnl_attr_type_valid(attr, CTRL_ATTR_MAX) < 0)
|
||||
return MNL_CB_ERROR;
|
||||
|
||||
if (type == CTRL_ATTR_FAMILY_ID &&
|
||||
mnl_attr_validate(attr, MNL_TYPE_U16) < 0)
|
||||
return MNL_CB_ERROR;
|
||||
tb[type] = attr;
|
||||
return MNL_CB_OK;
|
||||
}
|
||||
|
||||
static int get_family_id_cb(const struct nlmsghdr *nlh, void *data)
|
||||
{
|
||||
uint32_t *p_id = data;
|
||||
struct nlattr *tb[CTRL_ATTR_MAX + 1] = {};
|
||||
struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
|
||||
|
||||
mnl_attr_parse(nlh, sizeof(*genl), get_family_id_attr_cb, tb);
|
||||
if (!tb[CTRL_ATTR_FAMILY_ID])
|
||||
return MNL_CB_ERROR;
|
||||
*p_id = mnl_attr_get_u16(tb[CTRL_ATTR_FAMILY_ID]);
|
||||
return MNL_CB_OK;
|
||||
}
|
||||
|
||||
struct mnlg_socket *mnlg_socket_open(const char *family_name, uint8_t version)
|
||||
{
|
||||
struct mnlg_socket *nlg;
|
||||
struct nlmsghdr *nlh;
|
||||
int one = 1;
|
||||
int err;
|
||||
|
||||
nlg = malloc(sizeof(*nlg));
|
||||
if (!nlg)
|
||||
return NULL;
|
||||
|
||||
nlg->buf = malloc(MNL_SOCKET_BUFFER_SIZE);
|
||||
if (!nlg->buf)
|
||||
goto err_buf_alloc;
|
||||
|
||||
nlg->nl = mnl_socket_open(NETLINK_GENERIC);
|
||||
if (!nlg->nl)
|
||||
goto err_mnl_socket_open;
|
||||
|
||||
/* Older kernels may no support capped/extended ACK reporting */
|
||||
mnl_socket_setsockopt(nlg->nl, NETLINK_CAP_ACK, &one, sizeof(one));
|
||||
mnl_socket_setsockopt(nlg->nl, NETLINK_EXT_ACK, &one, sizeof(one));
|
||||
|
||||
err = mnl_socket_bind(nlg->nl, 0, MNL_SOCKET_AUTOPID);
|
||||
if (err < 0)
|
||||
goto err_mnl_socket_bind;
|
||||
|
||||
nlg->portid = mnl_socket_get_portid(nlg->nl);
|
||||
|
||||
nlh = __mnlg_msg_prepare(nlg, CTRL_CMD_GETFAMILY,
|
||||
NLM_F_REQUEST | NLM_F_ACK, GENL_ID_CTRL, 1);
|
||||
mnl_attr_put_strz(nlh, CTRL_ATTR_FAMILY_NAME, family_name);
|
||||
|
||||
err = mnlg_socket_send(nlg, nlh);
|
||||
if (err < 0)
|
||||
goto err_mnlg_socket_send;
|
||||
|
||||
err = mnlg_socket_recv_run(nlg, get_family_id_cb, &nlg->id);
|
||||
if (err < 0)
|
||||
goto err_mnlg_socket_recv_run;
|
||||
|
||||
nlg->version = version;
|
||||
return nlg;
|
||||
|
||||
err_mnlg_socket_recv_run:
|
||||
err_mnlg_socket_send:
|
||||
err_mnl_socket_bind:
|
||||
mnl_socket_close(nlg->nl);
|
||||
err_mnl_socket_open:
|
||||
free(nlg->buf);
|
||||
err_buf_alloc:
|
||||
free(nlg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void mnlg_socket_close(struct mnlg_socket *nlg)
|
||||
{
|
||||
mnl_socket_close(nlg->nl);
|
||||
free(nlg->buf);
|
||||
free(nlg);
|
||||
}
|
||||
|
||||
int mnlg_socket_get_fd(struct mnlg_socket *nlg)
|
||||
{
|
||||
return mnl_socket_get_fd(nlg->nl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,15 @@
|
|||
|
||||
#include <libmnl/libmnl.h>
|
||||
|
||||
struct mnlu_gen_socket;
|
||||
struct mnlg_socket;
|
||||
|
||||
int mnlg_socket_send(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh);
|
||||
int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name);
|
||||
int mnlg_socket_get_fd(struct mnlu_gen_socket *nlg);
|
||||
struct nlmsghdr *mnlg_msg_prepare(struct mnlg_socket *nlg, uint8_t cmd,
|
||||
uint16_t flags);
|
||||
int mnlg_socket_send(struct mnlg_socket *nlg, const struct nlmsghdr *nlh);
|
||||
int mnlg_socket_recv_run(struct mnlg_socket *nlg, mnl_cb_t data_cb, void *data);
|
||||
int mnlg_socket_group_add(struct mnlg_socket *nlg, const char *group_name);
|
||||
struct mnlg_socket *mnlg_socket_open(const char *family_name, uint8_t version);
|
||||
void mnlg_socket_close(struct mnlg_socket *nlg);
|
||||
int mnlg_socket_get_fd(struct mnlg_socket *nlg);
|
||||
|
||||
#endif /* _MNLG_H_ */
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Where:
|
|||
|
||||
ACTION semantics
|
||||
- pass and ok are equivalent to accept
|
||||
- continue allows one to restart classification lookup
|
||||
- continue allows to restart classification lookup
|
||||
- drop drops packets
|
||||
- reclassify implies continue classification where we left off
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,8 @@
|
|||
13 dnrouted
|
||||
14 xorp
|
||||
15 ntk
|
||||
16 dhcp
|
||||
18 keepalived
|
||||
16 dhcp
|
||||
42 babel
|
||||
99 openr
|
||||
186 bgp
|
||||
187 isis
|
||||
188 ospf
|
||||
|
|
|
|||
|
|
@ -1,18 +1,8 @@
|
|||
eBPF toy code examples (running in kernel) to familiarize yourself
|
||||
with syntax and features:
|
||||
|
||||
- BTF defined map examples
|
||||
- bpf_shared.c -> Ingress/egress map sharing example
|
||||
- bpf_tailcall.c -> Using tail call chains
|
||||
- bpf_cyclic.c -> Simple cycle as tail calls
|
||||
- bpf_graft.c -> Demo on altering runtime behaviour
|
||||
- bpf_shared.c -> Ingress/egress map sharing example
|
||||
- bpf_map_in_map.c -> Using map in map example
|
||||
|
||||
- legacy struct bpf_elf_map defined map examples
|
||||
- legacy/bpf_shared.c -> Ingress/egress map sharing example
|
||||
- legacy/bpf_tailcall.c -> Using tail call chains
|
||||
- legacy/bpf_cyclic.c -> Simple cycle as tail calls
|
||||
- legacy/bpf_graft.c -> Demo on altering runtime behaviour
|
||||
- legacy/bpf_map_in_map.c -> Using map in map example
|
||||
|
||||
Note: Users should use new BTF way to defined the maps, the examples
|
||||
in legacy folder which is using struct bpf_elf_map defined maps is not
|
||||
recommanded.
|
||||
- bpf_map_in_map.c -> Using map in map example
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "../../../include/bpf_api.h"
|
||||
#include "../../include/bpf_api.h"
|
||||
|
||||
/* Cyclic dependency example to test the kernel's runtime upper
|
||||
* bound on loops. Also demonstrates on how to use direct-actions,
|
||||
|
|
@ -33,13 +33,13 @@
|
|||
* [...]
|
||||
*/
|
||||
|
||||
struct {
|
||||
__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
|
||||
__uint(key_size, sizeof(uint32_t));
|
||||
__uint(value_size, sizeof(uint32_t));
|
||||
__uint(max_entries, 1);
|
||||
__uint(pinning, LIBBPF_PIN_BY_NAME);
|
||||
} jmp_tc __section(".maps");
|
||||
struct bpf_elf_map __section_maps jmp_tc = {
|
||||
.type = BPF_MAP_TYPE_PROG_ARRAY,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.pinning = PIN_GLOBAL_NS,
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
__section("aaa")
|
||||
int cls_aaa(struct __sk_buff *skb)
|
||||
|
|
|
|||
|
|
@ -1,23 +1,24 @@
|
|||
#include "../../include/bpf_api.h"
|
||||
|
||||
struct inner_map {
|
||||
__uint(type, BPF_MAP_TYPE_ARRAY);
|
||||
__uint(key_size, sizeof(uint32_t));
|
||||
__uint(value_size, sizeof(uint32_t));
|
||||
__uint(max_entries, 1);
|
||||
} map_inner __section(".maps");
|
||||
#define MAP_INNER_ID 42
|
||||
|
||||
struct {
|
||||
__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
|
||||
__uint(key_size, sizeof(uint32_t));
|
||||
__uint(value_size, sizeof(uint32_t));
|
||||
__uint(max_entries, 1);
|
||||
__uint(pinning, LIBBPF_PIN_BY_NAME);
|
||||
__array(values, struct inner_map);
|
||||
} map_outer __section(".maps") = {
|
||||
.values = {
|
||||
[0] = &map_inner,
|
||||
},
|
||||
struct bpf_elf_map __section_maps map_inner = {
|
||||
.type = BPF_MAP_TYPE_ARRAY,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.id = MAP_INNER_ID,
|
||||
.inner_idx = 0,
|
||||
.pinning = PIN_GLOBAL_NS,
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
struct bpf_elf_map __section_maps map_outer = {
|
||||
.type = BPF_MAP_TYPE_ARRAY_OF_MAPS,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.inner_id = MAP_INNER_ID,
|
||||
.pinning = PIN_GLOBAL_NS,
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
__section("egress")
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
* instance is being created.
|
||||
*/
|
||||
|
||||
struct {
|
||||
__uint(type, BPF_MAP_TYPE_ARRAY);
|
||||
__uint(key_size, sizeof(uint32_t));
|
||||
__uint(value_size, sizeof(uint32_t));
|
||||
__uint(max_entries, 1);
|
||||
__uint(pinning, LIBBPF_PIN_BY_NAME); /* or LIBBPF_PIN_NONE */
|
||||
} map_sh __section(".maps");
|
||||
struct bpf_elf_map __section_maps map_sh = {
|
||||
.type = BPF_MAP_TYPE_ARRAY,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.pinning = PIN_OBJECT_NS, /* or PIN_GLOBAL_NS, or PIN_NONE */
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
__section("egress")
|
||||
int emain(struct __sk_buff *skb)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include "../../../include/bpf_api.h"
|
||||
#include "../../include/bpf_api.h"
|
||||
|
||||
#define ENTRY_INIT 3
|
||||
#define ENTRY_0 0
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
#include "../../../include/bpf_api.h"
|
||||
|
||||
/* This example demonstrates how classifier run-time behaviour
|
||||
* can be altered with tail calls. We start out with an empty
|
||||
* jmp_tc array, then add section aaa to the array slot 0, and
|
||||
* later on atomically replace it with section bbb. Note that
|
||||
* as shown in other examples, the tc loader can prepopulate
|
||||
* tail called sections, here we start out with an empty one
|
||||
* on purpose to show it can also be done this way.
|
||||
*
|
||||
* tc filter add dev foo parent ffff: bpf obj graft.o
|
||||
* tc exec bpf dbg
|
||||
* [...]
|
||||
* Socket Thread-20229 [001] ..s. 138993.003923: : fallthrough
|
||||
* <idle>-0 [001] ..s. 138993.202265: : fallthrough
|
||||
* Socket Thread-20229 [001] ..s. 138994.004149: : fallthrough
|
||||
* [...]
|
||||
*
|
||||
* tc exec bpf graft m:globals/jmp_tc key 0 obj graft.o sec aaa
|
||||
* tc exec bpf dbg
|
||||
* [...]
|
||||
* Socket Thread-19818 [002] ..s. 139012.053587: : aaa
|
||||
* <idle>-0 [002] ..s. 139012.172359: : aaa
|
||||
* Socket Thread-19818 [001] ..s. 139012.173556: : aaa
|
||||
* [...]
|
||||
*
|
||||
* tc exec bpf graft m:globals/jmp_tc key 0 obj graft.o sec bbb
|
||||
* tc exec bpf dbg
|
||||
* [...]
|
||||
* Socket Thread-19818 [002] ..s. 139022.102967: : bbb
|
||||
* <idle>-0 [002] ..s. 139022.155640: : bbb
|
||||
* Socket Thread-19818 [001] ..s. 139022.156730: : bbb
|
||||
* [...]
|
||||
*/
|
||||
|
||||
struct bpf_elf_map __section_maps jmp_tc = {
|
||||
.type = BPF_MAP_TYPE_PROG_ARRAY,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.pinning = PIN_GLOBAL_NS,
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
__section("aaa")
|
||||
int cls_aaa(struct __sk_buff *skb)
|
||||
{
|
||||
printt("aaa\n");
|
||||
return TC_H_MAKE(1, 42);
|
||||
}
|
||||
|
||||
__section("bbb")
|
||||
int cls_bbb(struct __sk_buff *skb)
|
||||
{
|
||||
printt("bbb\n");
|
||||
return TC_H_MAKE(1, 43);
|
||||
}
|
||||
|
||||
__section_cls_entry
|
||||
int cls_entry(struct __sk_buff *skb)
|
||||
{
|
||||
tail_call(skb, &jmp_tc, 0);
|
||||
printt("fallthrough\n");
|
||||
return BPF_H_DEFAULT;
|
||||
}
|
||||
|
||||
BPF_LICENSE("GPL");
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#include "../../../include/bpf_api.h"
|
||||
|
||||
#define MAP_INNER_ID 42
|
||||
|
||||
struct bpf_elf_map __section_maps map_inner = {
|
||||
.type = BPF_MAP_TYPE_ARRAY,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.id = MAP_INNER_ID,
|
||||
.inner_idx = 0,
|
||||
.pinning = PIN_GLOBAL_NS,
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
struct bpf_elf_map __section_maps map_outer = {
|
||||
.type = BPF_MAP_TYPE_ARRAY_OF_MAPS,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.inner_id = MAP_INNER_ID,
|
||||
.pinning = PIN_GLOBAL_NS,
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
__section("egress")
|
||||
int emain(struct __sk_buff *skb)
|
||||
{
|
||||
struct bpf_elf_map *map_inner;
|
||||
int key = 0, *val;
|
||||
|
||||
map_inner = map_lookup_elem(&map_outer, &key);
|
||||
if (map_inner) {
|
||||
val = map_lookup_elem(map_inner, &key);
|
||||
if (val)
|
||||
lock_xadd(val, 1);
|
||||
}
|
||||
|
||||
return BPF_H_DEFAULT;
|
||||
}
|
||||
|
||||
__section("ingress")
|
||||
int imain(struct __sk_buff *skb)
|
||||
{
|
||||
struct bpf_elf_map *map_inner;
|
||||
int key = 0, *val;
|
||||
|
||||
map_inner = map_lookup_elem(&map_outer, &key);
|
||||
if (map_inner) {
|
||||
val = map_lookup_elem(map_inner, &key);
|
||||
if (val)
|
||||
printt("map val: %d\n", *val);
|
||||
}
|
||||
|
||||
return BPF_H_DEFAULT;
|
||||
}
|
||||
|
||||
BPF_LICENSE("GPL");
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#include "../../../include/bpf_api.h"
|
||||
|
||||
/* Minimal, stand-alone toy map pinning example:
|
||||
*
|
||||
* clang -target bpf -O2 [...] -o bpf_shared.o -c bpf_shared.c
|
||||
* tc filter add dev foo parent 1: bpf obj bpf_shared.o sec egress
|
||||
* tc filter add dev foo parent ffff: bpf obj bpf_shared.o sec ingress
|
||||
*
|
||||
* Both classifier will share the very same map instance in this example,
|
||||
* so map content can be accessed from ingress *and* egress side!
|
||||
*
|
||||
* This example has a pinning of PIN_OBJECT_NS, so it's private and
|
||||
* thus shared among various program sections within the object.
|
||||
*
|
||||
* A setting of PIN_GLOBAL_NS would place it into a global namespace,
|
||||
* so that it can be shared among different object files. A setting
|
||||
* of PIN_NONE (= 0) means no sharing, so each tc invocation a new map
|
||||
* instance is being created.
|
||||
*/
|
||||
|
||||
struct bpf_elf_map __section_maps map_sh = {
|
||||
.type = BPF_MAP_TYPE_ARRAY,
|
||||
.size_key = sizeof(uint32_t),
|
||||
.size_value = sizeof(uint32_t),
|
||||
.pinning = PIN_OBJECT_NS, /* or PIN_GLOBAL_NS, or PIN_NONE */
|
||||
.max_elem = 1,
|
||||
};
|
||||
|
||||
__section("egress")
|
||||
int emain(struct __sk_buff *skb)
|
||||
{
|
||||
int key = 0, *val;
|
||||
|
||||
val = map_lookup_elem(&map_sh, &key);
|
||||
if (val)
|
||||
lock_xadd(val, 1);
|
||||
|
||||
return BPF_H_DEFAULT;
|
||||
}
|
||||
|
||||
__section("ingress")
|
||||
int imain(struct __sk_buff *skb)
|
||||
{
|
||||
int key = 0, *val;
|
||||
|
||||
val = map_lookup_elem(&map_sh, &key);
|
||||
if (val)
|
||||
printt("map val: %d\n", *val);
|
||||
|
||||
return BPF_H_DEFAULT;
|
||||
}
|
||||
|
||||
BPF_LICENSE("GPL");
|
||||
51
genl/ctrl.c
51
genl/ctrl.c
|
|
@ -28,15 +28,13 @@
|
|||
static int usage(void)
|
||||
{
|
||||
fprintf(stderr,"Usage: ctrl <CMD>\n" \
|
||||
"CMD := get <PARMS> | list | monitor | policy <PARMS>\n" \
|
||||
"CMD := get <PARMS> | list | monitor\n" \
|
||||
"PARMS := name <name> | id <id>\n" \
|
||||
"Examples:\n" \
|
||||
"\tctrl ls\n" \
|
||||
"\tctrl monitor\n" \
|
||||
"\tctrl get name foobar\n" \
|
||||
"\tctrl get id 0xF\n"
|
||||
"\tctrl policy name foobar\n"
|
||||
"\tctrl policy id 0xF\n");
|
||||
"\tctrl get id 0xF\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -125,8 +123,7 @@ static int print_ctrl(struct rtnl_ctrl_data *ctrl,
|
|||
ghdr->cmd != CTRL_CMD_DELFAMILY &&
|
||||
ghdr->cmd != CTRL_CMD_NEWFAMILY &&
|
||||
ghdr->cmd != CTRL_CMD_NEWMCAST_GRP &&
|
||||
ghdr->cmd != CTRL_CMD_DELMCAST_GRP &&
|
||||
ghdr->cmd != CTRL_CMD_GETPOLICY) {
|
||||
ghdr->cmd != CTRL_CMD_DELMCAST_GRP) {
|
||||
fprintf(stderr, "Unknown controller command %d\n", ghdr->cmd);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -139,7 +136,7 @@ static int print_ctrl(struct rtnl_ctrl_data *ctrl,
|
|||
}
|
||||
|
||||
attrs = (struct rtattr *) ((char *) ghdr + GENL_HDRLEN);
|
||||
parse_rtattr_flags(tb, CTRL_ATTR_MAX, attrs, len, NLA_F_NESTED);
|
||||
parse_rtattr(tb, CTRL_ATTR_MAX, attrs, len);
|
||||
|
||||
if (tb[CTRL_ATTR_FAMILY_NAME]) {
|
||||
char *name = RTA_DATA(tb[CTRL_ATTR_FAMILY_NAME]);
|
||||
|
|
@ -162,36 +159,6 @@ static int print_ctrl(struct rtnl_ctrl_data *ctrl,
|
|||
__u32 *ma = RTA_DATA(tb[CTRL_ATTR_MAXATTR]);
|
||||
fprintf(fp, " max attribs: %d ",*ma);
|
||||
}
|
||||
if (tb[CTRL_ATTR_OP_POLICY]) {
|
||||
const struct rtattr *pos;
|
||||
|
||||
rtattr_for_each_nested(pos, tb[CTRL_ATTR_OP_POLICY]) {
|
||||
struct rtattr *ptb[CTRL_ATTR_POLICY_DUMP_MAX + 1];
|
||||
struct rtattr *pattrs = RTA_DATA(pos);
|
||||
int plen = RTA_PAYLOAD(pos);
|
||||
|
||||
parse_rtattr_flags(ptb, CTRL_ATTR_POLICY_DUMP_MAX,
|
||||
pattrs, plen, NLA_F_NESTED);
|
||||
|
||||
fprintf(fp, " op %d policies:",
|
||||
pos->rta_type & ~NLA_F_NESTED);
|
||||
|
||||
if (ptb[CTRL_ATTR_POLICY_DO]) {
|
||||
__u32 *v = RTA_DATA(ptb[CTRL_ATTR_POLICY_DO]);
|
||||
|
||||
fprintf(fp, " do=%d", *v);
|
||||
}
|
||||
|
||||
if (ptb[CTRL_ATTR_POLICY_DUMP]) {
|
||||
__u32 *v = RTA_DATA(ptb[CTRL_ATTR_POLICY_DUMP]);
|
||||
|
||||
fprintf(fp, " dump=%d", *v);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tb[CTRL_ATTR_POLICY])
|
||||
nl_print_policy(tb[CTRL_ATTR_POLICY], fp);
|
||||
|
||||
/* end of family definitions .. */
|
||||
fprintf(fp,"\n");
|
||||
if (tb[CTRL_ATTR_OPS]) {
|
||||
|
|
@ -268,9 +235,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (cmd == CTRL_CMD_GETFAMILY || cmd == CTRL_CMD_GETPOLICY) {
|
||||
req.g.cmd = cmd;
|
||||
|
||||
if (cmd == CTRL_CMD_GETFAMILY) {
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Wrong number of params\n");
|
||||
return -1;
|
||||
|
|
@ -295,9 +260,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
|
|||
fprintf(stderr, "Wrong params\n");
|
||||
goto ctrl_done;
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd == CTRL_CMD_GETFAMILY) {
|
||||
if (rtnl_talk(&rth, nlh, &answer) < 0) {
|
||||
fprintf(stderr, "Error talking to the kernel\n");
|
||||
goto ctrl_done;
|
||||
|
|
@ -310,7 +273,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
|
|||
|
||||
}
|
||||
|
||||
if (cmd == CTRL_CMD_UNSPEC || cmd == CTRL_CMD_GETPOLICY) {
|
||||
if (cmd == CTRL_CMD_UNSPEC) {
|
||||
nlh->nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
|
||||
nlh->nlmsg_seq = rth.dump = ++rth.seq;
|
||||
|
||||
|
|
@ -361,8 +324,6 @@ static int parse_ctrl(struct genl_util *a, int argc, char **argv)
|
|||
matches(*argv, "show") == 0 ||
|
||||
matches(*argv, "lst") == 0)
|
||||
return ctrl_list(CTRL_CMD_UNSPEC, argc-1, argv+1);
|
||||
if (matches(*argv, "policy") == 0)
|
||||
return ctrl_list(CTRL_CMD_GETPOLICY, argc-1, argv+1);
|
||||
if (matches(*argv, "help") == 0)
|
||||
return usage();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <errno.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h> /* until we put our own header */
|
||||
#include "version.h"
|
||||
#include "SNAPSHOT.h"
|
||||
#include "utils.h"
|
||||
#include "genl_utils.h"
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ int main(int argc, char **argv)
|
|||
} else if (matches(argv[1], "-raw") == 0) {
|
||||
++show_raw;
|
||||
} else if (matches(argv[1], "-Version") == 0) {
|
||||
printf("genl utility, iproute2-%s\n", version);
|
||||
printf("genl utility, iproute2-ss%s\n", SNAPSHOT);
|
||||
exit(0);
|
||||
} else if (matches(argv[1], "-help") == 0) {
|
||||
usage();
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
#ifndef _TC_UTIL_H_
|
||||
#define _TC_UTIL_H_ 1
|
||||
|
||||
#include <linux/genetlink.h>
|
||||
#include "utils.h"
|
||||
#include "linux/genetlink.h"
|
||||
|
||||
struct genl_util {
|
||||
struct genl_util
|
||||
{
|
||||
struct genl_util *next;
|
||||
char name[16];
|
||||
int (*parse_genlopt)(struct genl_util *fu, int argc, char **argv);
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
static const char SNAPSHOT[] = "200602";
|
||||
|
|
@ -19,19 +19,6 @@
|
|||
|
||||
#include "bpf_elf.h"
|
||||
|
||||
/** libbpf pin type. */
|
||||
enum libbpf_pin_type {
|
||||
LIBBPF_PIN_NONE,
|
||||
/* PIN_BY_NAME: pin maps by name (in /sys/fs/bpf by default) */
|
||||
LIBBPF_PIN_BY_NAME,
|
||||
};
|
||||
|
||||
/** Type helper macros. */
|
||||
|
||||
#define __uint(name, val) int (*name)[val]
|
||||
#define __type(name, val) typeof(val) *name
|
||||
#define __array(name, val) typeof(val) *name[]
|
||||
|
||||
/** Misc macros. */
|
||||
|
||||
#ifndef __stringify
|
||||
|
|
|
|||
|
|
@ -274,16 +274,12 @@ int bpf_trace_pipe(void);
|
|||
|
||||
void bpf_print_ops(struct rtattr *bpf_ops, __u16 len);
|
||||
|
||||
int bpf_prog_load_dev(enum bpf_prog_type type, const struct bpf_insn *insns,
|
||||
size_t size_insns, const char *license, __u32 ifindex,
|
||||
char *log, size_t size_log);
|
||||
int bpf_program_load(enum bpf_prog_type type, const struct bpf_insn *insns,
|
||||
size_t size_insns, const char *license, char *log,
|
||||
size_t size_log);
|
||||
int bpf_prog_load(enum bpf_prog_type type, const struct bpf_insn *insns,
|
||||
size_t size_insns, const char *license, char *log,
|
||||
size_t size_log);
|
||||
|
||||
int bpf_prog_attach_fd(int prog_fd, int target_fd, enum bpf_attach_type type);
|
||||
int bpf_prog_detach_fd(int target_fd, enum bpf_attach_type type);
|
||||
int bpf_program_attach(int prog_fd, int target_fd, enum bpf_attach_type type);
|
||||
|
||||
int bpf_dump_prog_info(FILE *f, uint32_t id);
|
||||
|
||||
|
|
@ -291,16 +287,6 @@ int bpf_dump_prog_info(FILE *f, uint32_t id);
|
|||
int bpf_send_map_fds(const char *path, const char *obj);
|
||||
int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
|
||||
unsigned int entries);
|
||||
#ifdef HAVE_LIBBPF
|
||||
int iproute2_bpf_elf_ctx_init(struct bpf_cfg_in *cfg);
|
||||
int iproute2_bpf_fetch_ancillary(void);
|
||||
int iproute2_get_root_path(char *root_path, size_t len);
|
||||
bool iproute2_is_pin_map(const char *libbpf_map_name, char *pathname);
|
||||
bool iproute2_is_map_in_map(const char *libbpf_map_name, struct bpf_elf_map *imap,
|
||||
struct bpf_elf_map *omap, char *omap_name);
|
||||
int iproute2_find_map_name_by_id(unsigned int map_id, char *name);
|
||||
int iproute2_load_libbpf(struct bpf_cfg_in *cfg);
|
||||
#endif /* HAVE_LIBBPF */
|
||||
#else
|
||||
static inline int bpf_send_map_fds(const char *path, const char *obj)
|
||||
{
|
||||
|
|
@ -313,15 +299,5 @@ static inline int bpf_recv_map_fds(const char *path, int *fds,
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
#ifdef HAVE_LIBBPF
|
||||
static inline int iproute2_load_libbpf(struct bpf_cfg_in *cfg)
|
||||
{
|
||||
fprintf(stderr, "No ELF library support compiled in.\n");
|
||||
return -1;
|
||||
}
|
||||
#endif /* HAVE_LIBBPF */
|
||||
#endif /* HAVE_ELF */
|
||||
|
||||
const char *get_libbpf_version(void);
|
||||
|
||||
#endif /* __BPF_UTIL__ */
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef __CG_MAP_H__
|
||||
#define __CG_MAP_H__
|
||||
|
||||
const char *cg_id_to_path(__u64 id);
|
||||
|
||||
#endif /* __CG_MAP_H__ */
|
||||
|
|
@ -12,7 +12,7 @@ extern int do_command4(int argc, char *argv[], char **table,
|
|||
struct xtc_handle **handle, bool restore);
|
||||
extern int delete_chain4(const xt_chainlabel chain, int verbose,
|
||||
struct xtc_handle *handle);
|
||||
extern int flush_entries4(const xt_chainlabel chain, int verbose,
|
||||
extern int flush_entries4(const xt_chainlabel chain, int verbose,
|
||||
struct xtc_handle *handle);
|
||||
extern int for_each_chain4(int (*fn)(const xt_chainlabel, int, struct xtc_handle *),
|
||||
int verbose, int builtinstoo, struct xtc_handle *handle);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
#include "json_writer.h"
|
||||
#include "color.h"
|
||||
|
||||
#define _IS_JSON_CONTEXT(type) (is_json_context() && (type & PRINT_JSON || type & PRINT_ANY))
|
||||
#define _IS_FP_CONTEXT(type) (!is_json_context() && (type & PRINT_FP || type & PRINT_ANY))
|
||||
|
||||
json_writer_t *get_json_writer(void);
|
||||
|
||||
/*
|
||||
|
|
@ -68,11 +65,9 @@ void print_nl(void);
|
|||
_PRINT_FUNC(int, int)
|
||||
_PRINT_FUNC(s64, int64_t)
|
||||
_PRINT_FUNC(bool, bool)
|
||||
_PRINT_FUNC(on_off, bool)
|
||||
_PRINT_FUNC(null, const char*)
|
||||
_PRINT_FUNC(string, const char*)
|
||||
_PRINT_FUNC(uint, unsigned int)
|
||||
_PRINT_FUNC(size, __u32)
|
||||
_PRINT_FUNC(u64, uint64_t)
|
||||
_PRINT_FUNC(hhu, unsigned char)
|
||||
_PRINT_FUNC(hu, unsigned short)
|
||||
|
|
@ -81,7 +76,6 @@ _PRINT_FUNC(0xhex, unsigned long long)
|
|||
_PRINT_FUNC(luint, unsigned long)
|
||||
_PRINT_FUNC(lluint, unsigned long long)
|
||||
_PRINT_FUNC(float, double)
|
||||
_PRINT_FUNC(tv, const struct timeval *)
|
||||
#undef _PRINT_FUNC
|
||||
|
||||
#define _PRINT_NAME_VALUE_FUNC(type_name, type, format_char) \
|
||||
|
|
@ -91,17 +85,4 @@ _PRINT_NAME_VALUE_FUNC(uint, unsigned int, u);
|
|||
_PRINT_NAME_VALUE_FUNC(string, const char*, s);
|
||||
#undef _PRINT_NAME_VALUE_FUNC
|
||||
|
||||
int print_color_rate(bool use_iec, enum output_type t, enum color_attr color,
|
||||
const char *key, const char *fmt, unsigned long long rate);
|
||||
|
||||
static inline int print_rate(bool use_iec, enum output_type t,
|
||||
const char *key, const char *fmt,
|
||||
unsigned long long rate)
|
||||
{
|
||||
return print_color_rate(use_iec, t, COLOR_NONE, key, fmt, rate);
|
||||
}
|
||||
|
||||
/* A backdoor to the size formatter. Please use print_size() instead. */
|
||||
char *sprint_size(__u32 sz, char *buf);
|
||||
|
||||
#endif /* _JSON_PRINT_H_ */
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ struct { \
|
|||
}, \
|
||||
}
|
||||
|
||||
int genl_add_mcast_grp(struct rtnl_handle *grth, __u16 genl_family, const char *group);
|
||||
int genl_resolve_family(struct rtnl_handle *grth, const char *family);
|
||||
int genl_init_handle(struct rtnl_handle *grth, const char *family,
|
||||
int *genl_family);
|
||||
|
|
|
|||
|
|
@ -69,8 +69,6 @@ int rtnl_neightbldump_req(struct rtnl_handle *rth, int family)
|
|||
__attribute__((warn_unused_result));
|
||||
int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
|
||||
__attribute__((warn_unused_result));
|
||||
int rtnl_brvlandump_req(struct rtnl_handle *rth, int family, __u32 dump_flags)
|
||||
__attribute__((warn_unused_result));
|
||||
int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
|
|
@ -99,9 +97,6 @@ int rtnl_dump_request_n(struct rtnl_handle *rth, struct nlmsghdr *n)
|
|||
int rtnl_nexthopdump_req(struct rtnl_handle *rth, int family,
|
||||
req_filter_fn_t filter_fn)
|
||||
__attribute__((warn_unused_result));
|
||||
int rtnl_nexthop_bucket_dump_req(struct rtnl_handle *rth, int family,
|
||||
req_filter_fn_t filter_fn)
|
||||
__attribute__((warn_unused_result));
|
||||
|
||||
struct rtnl_ctrl_data {
|
||||
int nsid;
|
||||
|
|
@ -109,27 +104,6 @@ struct rtnl_ctrl_data {
|
|||
|
||||
typedef int (*rtnl_filter_t)(struct nlmsghdr *n, void *);
|
||||
|
||||
/**
|
||||
* rtnl error handler called from
|
||||
* rtnl_dump_done()
|
||||
* rtnl_dump_error()
|
||||
*
|
||||
* Return value is a bitmask of the following values:
|
||||
* RTNL_LET_NLERR
|
||||
* error handled as usual
|
||||
* RTNL_SUPPRESS_NLMSG_DONE_NLERR
|
||||
* error in nlmsg_type == NLMSG_DONE will be suppressed
|
||||
* RTNL_SUPPRESS_NLMSG_ERROR_NLERR
|
||||
* error in nlmsg_type == NLMSG_ERROR will be suppressed
|
||||
* and nlmsg will be skipped
|
||||
* RTNL_SUPPRESS_NLERR - suppress error in both previous cases
|
||||
*/
|
||||
#define RTNL_LET_NLERR 0x01
|
||||
#define RTNL_SUPPRESS_NLMSG_DONE_NLERR 0x02
|
||||
#define RTNL_SUPPRESS_NLMSG_ERROR_NLERR 0x04
|
||||
#define RTNL_SUPPRESS_NLERR 0x06
|
||||
typedef int (*rtnl_err_hndlr_t)(struct nlmsghdr *n, void *);
|
||||
|
||||
typedef int (*rtnl_listen_filter_t)(struct rtnl_ctrl_data *,
|
||||
struct nlmsghdr *n, void *);
|
||||
|
||||
|
|
@ -139,8 +113,6 @@ typedef int (*nl_ext_ack_fn_t)(const char *errmsg, uint32_t off,
|
|||
struct rtnl_dump_filter_arg {
|
||||
rtnl_filter_t filter;
|
||||
void *arg1;
|
||||
rtnl_err_hndlr_t errhndlr;
|
||||
void *arg2;
|
||||
__u16 nc_flags;
|
||||
};
|
||||
|
||||
|
|
@ -149,15 +121,6 @@ int rtnl_dump_filter_nc(struct rtnl_handle *rth,
|
|||
void *arg, __u16 nc_flags);
|
||||
#define rtnl_dump_filter(rth, filter, arg) \
|
||||
rtnl_dump_filter_nc(rth, filter, arg, 0)
|
||||
int rtnl_dump_filter_errhndlr_nc(struct rtnl_handle *rth,
|
||||
rtnl_filter_t filter,
|
||||
void *arg1,
|
||||
rtnl_err_hndlr_t errhndlr,
|
||||
void *arg2,
|
||||
__u16 nc_flags);
|
||||
#define rtnl_dump_filter_errhndlr(rth, filter, farg, errhndlr, earg) \
|
||||
rtnl_dump_filter_errhndlr_nc(rth, filter, farg, errhndlr, earg, 0)
|
||||
|
||||
int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
|
||||
struct nlmsghdr **answer)
|
||||
__attribute__((warn_unused_result));
|
||||
|
|
@ -317,20 +280,8 @@ int rtnl_from_file(FILE *, rtnl_listen_filter_t handler,
|
|||
((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct if_stats_msg))))
|
||||
#endif
|
||||
|
||||
#ifndef BRVLAN_RTA
|
||||
#define BRVLAN_RTA(r) \
|
||||
((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct br_vlan_msg))))
|
||||
#endif
|
||||
|
||||
/* User defined nlmsg_type which is used mostly for logging netlink
|
||||
* messages from dump file */
|
||||
#define NLMSG_TSTAMP 15
|
||||
|
||||
#define rtattr_for_each_nested(attr, nest) \
|
||||
for ((attr) = (void *)RTA_DATA(nest); \
|
||||
RTA_OK(attr, RTA_PAYLOAD(nest) - ((char *)(attr) - (char *)RTA_DATA((nest)))); \
|
||||
(attr) = RTA_TAIL((attr)))
|
||||
|
||||
void nl_print_policy(const struct rtattr *attr, FILE *fp);
|
||||
|
||||
#endif /* __LIBNETLINK_H__ */
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef __MNL_UTILS_H__
|
||||
#define __MNL_UTILS_H__ 1
|
||||
|
||||
struct mnlu_gen_socket {
|
||||
struct mnl_socket *nl;
|
||||
char *buf;
|
||||
uint32_t family;
|
||||
unsigned int seq;
|
||||
uint8_t version;
|
||||
};
|
||||
|
||||
int mnlu_gen_socket_open(struct mnlu_gen_socket *nlg, const char *family_name,
|
||||
uint8_t version);
|
||||
void mnlu_gen_socket_close(struct mnlu_gen_socket *nlg);
|
||||
struct nlmsghdr *
|
||||
_mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
|
||||
uint8_t cmd, uint16_t flags,
|
||||
uint32_t id, uint8_t version);
|
||||
struct nlmsghdr *mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
|
||||
uint8_t cmd, uint16_t flags);
|
||||
int mnlu_gen_socket_sndrcv(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh,
|
||||
mnl_cb_t data_cb, void *data);
|
||||
|
||||
struct mnl_socket *mnlu_socket_open(int bus);
|
||||
struct nlmsghdr *mnlu_msg_prepare(void *buf, uint32_t nlmsg_type, uint16_t flags,
|
||||
void *extra_header, size_t extra_header_size);
|
||||
int mnlu_socket_recv_run(struct mnl_socket *nl, unsigned int seq, void *buf, size_t buf_size,
|
||||
mnl_cb_t cb, void *data);
|
||||
int mnlu_gen_socket_recv_run(struct mnlu_gen_socket *nlg, mnl_cb_t cb,
|
||||
void *data);
|
||||
|
||||
#endif /* __MNL_UTILS_H__ */
|
||||
|
|
@ -9,7 +9,6 @@ const char *rtnl_rtscope_n2a(int id, char *buf, int len);
|
|||
const char *rtnl_rttable_n2a(__u32 id, char *buf, int len);
|
||||
const char *rtnl_rtrealm_n2a(int id, char *buf, int len);
|
||||
const char *rtnl_dsfield_n2a(int id, char *buf, int len);
|
||||
const char *rtnl_dsfield_get_name(int id);
|
||||
const char *rtnl_group_n2a(int id, char *buf, int len);
|
||||
|
||||
int rtnl_rtprot_a2n(__u32 *id, const char *arg);
|
||||
|
|
@ -34,9 +33,6 @@ int ll_proto_a2n(unsigned short *id, const char *buf);
|
|||
const char *nl_proto_n2a(int id, char *buf, int len);
|
||||
int nl_proto_a2n(__u32 *id, const char *arg);
|
||||
|
||||
int protodown_reason_a2n(__u32 *id, const char *arg);
|
||||
int protodown_reason_n2a(int id, char *buf, int len);
|
||||
|
||||
extern int numeric;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
|
||||
/*
|
||||
* Copyright (c) 2021 Taehee Yoo <ap420073@gmail.com>
|
||||
*/
|
||||
#ifndef _AMT_H_
|
||||
#define _AMT_H_
|
||||
|
||||
enum ifla_amt_mode {
|
||||
/* AMT interface works as Gateway mode.
|
||||
* The Gateway mode encapsulates IGMP/MLD traffic and decapsulates
|
||||
* multicast traffic.
|
||||
*/
|
||||
AMT_MODE_GATEWAY = 0,
|
||||
/* AMT interface works as Relay mode.
|
||||
* The Relay mode encapsulates multicast traffic and decapsulates
|
||||
* IGMP/MLD traffic.
|
||||
*/
|
||||
AMT_MODE_RELAY,
|
||||
__AMT_MODE_MAX,
|
||||
};
|
||||
|
||||
#define AMT_MODE_MAX (__AMT_MODE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_AMT_UNSPEC,
|
||||
/* This attribute specify mode etier Gateway or Relay. */
|
||||
IFLA_AMT_MODE,
|
||||
/* This attribute specify Relay port.
|
||||
* AMT interface is created as Gateway mode, this attribute is used
|
||||
* to specify relay(remote) port.
|
||||
* AMT interface is created as Relay mode, this attribute is used
|
||||
* as local port.
|
||||
*/
|
||||
IFLA_AMT_RELAY_PORT,
|
||||
/* This attribute specify Gateway port.
|
||||
* AMT interface is created as Gateway mode, this attribute is used
|
||||
* as local port.
|
||||
* AMT interface is created as Relay mode, this attribute is not used.
|
||||
*/
|
||||
IFLA_AMT_GATEWAY_PORT,
|
||||
/* This attribute specify physical device */
|
||||
IFLA_AMT_LINK,
|
||||
/* This attribute specify local ip address */
|
||||
IFLA_AMT_LOCAL_IP,
|
||||
/* This attribute specify Relay ip address.
|
||||
* So, this is not used by Relay.
|
||||
*/
|
||||
IFLA_AMT_REMOTE_IP,
|
||||
/* This attribute specify Discovery ip address.
|
||||
* When Gateway get started, it send discovery message to find the
|
||||
* Relay's ip address.
|
||||
* So, this is not used by Relay.
|
||||
*/
|
||||
IFLA_AMT_DISCOVERY_IP,
|
||||
/* This attribute specify number of maximum tunnel. */
|
||||
IFLA_AMT_MAX_TUNNELS,
|
||||
__IFLA_AMT_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_AMT_MAX (__IFLA_AMT_MAX - 1)
|
||||
|
||||
#endif /* _AMT_H_ */
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
|
||||
/*
|
||||
* See https://icawww1.epfl.ch/linux-atm/magic.html for the complete list of
|
||||
* See http://icawww1.epfl.ch/linux-atm/magic.html for the complete list of
|
||||
* "magic" ioctl numbers.
|
||||
*/
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -43,7 +43,7 @@ struct btf_type {
|
|||
* "size" tells the size of the type it is describing.
|
||||
*
|
||||
* "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
|
||||
* FUNC, FUNC_PROTO, VAR and DECL_TAG.
|
||||
* FUNC, FUNC_PROTO and VAR.
|
||||
* "type" is a type_id referring to another type.
|
||||
*/
|
||||
union {
|
||||
|
|
@ -52,33 +52,28 @@ struct btf_type {
|
|||
};
|
||||
};
|
||||
|
||||
#define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f)
|
||||
#define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f)
|
||||
#define BTF_INFO_VLEN(info) ((info) & 0xffff)
|
||||
#define BTF_INFO_KFLAG(info) ((info) >> 31)
|
||||
|
||||
enum {
|
||||
BTF_KIND_UNKN = 0, /* Unknown */
|
||||
BTF_KIND_INT = 1, /* Integer */
|
||||
BTF_KIND_PTR = 2, /* Pointer */
|
||||
BTF_KIND_ARRAY = 3, /* Array */
|
||||
BTF_KIND_STRUCT = 4, /* Struct */
|
||||
BTF_KIND_UNION = 5, /* Union */
|
||||
BTF_KIND_ENUM = 6, /* Enumeration */
|
||||
BTF_KIND_FWD = 7, /* Forward */
|
||||
BTF_KIND_TYPEDEF = 8, /* Typedef */
|
||||
BTF_KIND_VOLATILE = 9, /* Volatile */
|
||||
BTF_KIND_CONST = 10, /* Const */
|
||||
BTF_KIND_RESTRICT = 11, /* Restrict */
|
||||
BTF_KIND_FUNC = 12, /* Function */
|
||||
BTF_KIND_FUNC_PROTO = 13, /* Function Proto */
|
||||
BTF_KIND_VAR = 14, /* Variable */
|
||||
BTF_KIND_DATASEC = 15, /* Section */
|
||||
BTF_KIND_FLOAT = 16, /* Floating point */
|
||||
BTF_KIND_DECL_TAG = 17, /* Decl Tag */
|
||||
|
||||
NR_BTF_KINDS,
|
||||
BTF_KIND_MAX = NR_BTF_KINDS - 1,
|
||||
};
|
||||
#define BTF_KIND_UNKN 0 /* Unknown */
|
||||
#define BTF_KIND_INT 1 /* Integer */
|
||||
#define BTF_KIND_PTR 2 /* Pointer */
|
||||
#define BTF_KIND_ARRAY 3 /* Array */
|
||||
#define BTF_KIND_STRUCT 4 /* Struct */
|
||||
#define BTF_KIND_UNION 5 /* Union */
|
||||
#define BTF_KIND_ENUM 6 /* Enumeration */
|
||||
#define BTF_KIND_FWD 7 /* Forward */
|
||||
#define BTF_KIND_TYPEDEF 8 /* Typedef */
|
||||
#define BTF_KIND_VOLATILE 9 /* Volatile */
|
||||
#define BTF_KIND_CONST 10 /* Const */
|
||||
#define BTF_KIND_RESTRICT 11 /* Restrict */
|
||||
#define BTF_KIND_FUNC 12 /* Function */
|
||||
#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
|
||||
#define BTF_KIND_VAR 14 /* Variable */
|
||||
#define BTF_KIND_DATASEC 15 /* Section */
|
||||
#define BTF_KIND_MAX BTF_KIND_DATASEC
|
||||
#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
|
||||
|
||||
/* For some specific BTF_KIND, "struct btf_type" is immediately
|
||||
* followed by extra data.
|
||||
|
|
@ -174,15 +169,4 @@ struct btf_var_secinfo {
|
|||
__u32 size;
|
||||
};
|
||||
|
||||
/* BTF_KIND_DECL_TAG is followed by a single "struct btf_decl_tag" to describe
|
||||
* additional information related to the tag applied location.
|
||||
* If component_idx == -1, the tag is applied to a struct, union,
|
||||
* variable or function. Otherwise, it is applied to a struct/union
|
||||
* member or a func argument, and component_idx indicates which member
|
||||
* or argument (0 ... vlen-1).
|
||||
*/
|
||||
struct btf_decl_tag {
|
||||
__s32 component_idx;
|
||||
};
|
||||
|
||||
#endif /* __LINUX_BTF_H__ */
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ typedef __u32 can_err_mask_t;
|
|||
|
||||
/* CAN payload length and DLC definitions according to ISO 11898-1 */
|
||||
#define CAN_MAX_DLC 8
|
||||
#define CAN_MAX_RAW_DLC 15
|
||||
#define CAN_MAX_DLEN 8
|
||||
|
||||
/* CAN FD payload length and DLC definitions according to ISO 11898-7 */
|
||||
|
|
@ -92,39 +91,30 @@ typedef __u32 can_err_mask_t;
|
|||
#define CANFD_MAX_DLEN 64
|
||||
|
||||
/**
|
||||
* struct can_frame - Classical CAN frame structure (aka CAN 2.0B)
|
||||
* @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
|
||||
* @len: CAN frame payload length in byte (0 .. 8)
|
||||
* @can_dlc: deprecated name for CAN frame payload length in byte (0 .. 8)
|
||||
* @__pad: padding
|
||||
* @__res0: reserved / padding
|
||||
* @len8_dlc: optional DLC value (9 .. 15) at 8 byte payload length
|
||||
* len8_dlc contains values from 9 .. 15 when the payload length is
|
||||
* 8 bytes but the DLC value (see ISO 11898-1) is greater then 8.
|
||||
* CAN_CTRLMODE_CC_LEN8_DLC flag has to be enabled in CAN driver.
|
||||
* @data: CAN frame payload (up to 8 byte)
|
||||
* struct can_frame - basic CAN frame structure
|
||||
* @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
|
||||
* @can_dlc: frame payload length in byte (0 .. 8) aka data length code
|
||||
* N.B. the DLC field from ISO 11898-1 Chapter 8.4.2.3 has a 1:1
|
||||
* mapping of the 'data length code' to the real payload length
|
||||
* @__pad: padding
|
||||
* @__res0: reserved / padding
|
||||
* @__res1: reserved / padding
|
||||
* @data: CAN frame payload (up to 8 byte)
|
||||
*/
|
||||
struct can_frame {
|
||||
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
|
||||
union {
|
||||
/* CAN frame payload length in byte (0 .. CAN_MAX_DLEN)
|
||||
* was previously named can_dlc so we need to carry that
|
||||
* name for legacy support
|
||||
*/
|
||||
__u8 len;
|
||||
__u8 can_dlc; /* deprecated */
|
||||
} __attribute__((packed)); /* disable padding added in some ABIs */
|
||||
__u8 __pad; /* padding */
|
||||
__u8 __res0; /* reserved / padding */
|
||||
__u8 len8_dlc; /* optional DLC for 8 byte payload length (9 .. 15) */
|
||||
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
|
||||
__u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
|
||||
__u8 __pad; /* padding */
|
||||
__u8 __res0; /* reserved / padding */
|
||||
__u8 __res1; /* reserved / padding */
|
||||
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
|
||||
};
|
||||
|
||||
/*
|
||||
* defined bits for canfd_frame.flags
|
||||
*
|
||||
* The use of struct canfd_frame implies the FD Frame (FDF) bit to
|
||||
* be set in the CAN frame bitstream on the wire. The FDF bit switch turns
|
||||
* The use of struct canfd_frame implies the Extended Data Length (EDL) bit to
|
||||
* be set in the CAN frame bitstream on the wire. The EDL bit switch turns
|
||||
* the CAN controllers bitstream processor into the CAN FD mode which creates
|
||||
* two new options within the CAN FD frame specification:
|
||||
*
|
||||
|
|
@ -135,18 +125,9 @@ struct can_frame {
|
|||
* controller only the CANFD_BRS bit is relevant for real CAN controllers when
|
||||
* building a CAN FD frame for transmission. Setting the CANFD_ESI bit can make
|
||||
* sense for virtual CAN interfaces to test applications with echoed frames.
|
||||
*
|
||||
* The struct can_frame and struct canfd_frame intentionally share the same
|
||||
* layout to be able to write CAN frame content into a CAN FD frame structure.
|
||||
* When this is done the former differentiation via CAN_MTU / CANFD_MTU gets
|
||||
* lost. CANFD_FDF allows programmers to mark CAN FD frames in the case of
|
||||
* using struct canfd_frame for mixed CAN / CAN FD content (dual use).
|
||||
* N.B. the Kernel APIs do NOT provide mixed CAN / CAN FD content inside of
|
||||
* struct canfd_frame therefore the CANFD_FDF flag is disregarded by Linux.
|
||||
*/
|
||||
#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
|
||||
#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
|
||||
#define CANFD_FDF 0x04 /* mark CAN FD for dual use of struct canfd_frame */
|
||||
|
||||
/**
|
||||
* struct canfd_frame - CAN flexible data rate frame structure
|
||||
|
|
|
|||
|
|
@ -100,9 +100,6 @@ struct can_ctrlmode {
|
|||
#define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
|
||||
#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
|
||||
#define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
|
||||
#define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */
|
||||
#define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN transiver automatically calculates TDCV */
|
||||
#define CAN_CTRLMODE_TDC_MANUAL 0x400 /* TDCV is manually set up by user */
|
||||
|
||||
/*
|
||||
* CAN device statistics
|
||||
|
|
@ -136,35 +133,10 @@ enum {
|
|||
IFLA_CAN_BITRATE_CONST,
|
||||
IFLA_CAN_DATA_BITRATE_CONST,
|
||||
IFLA_CAN_BITRATE_MAX,
|
||||
IFLA_CAN_TDC,
|
||||
|
||||
/* add new constants above here */
|
||||
__IFLA_CAN_MAX,
|
||||
IFLA_CAN_MAX = __IFLA_CAN_MAX - 1
|
||||
__IFLA_CAN_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
* CAN FD Transmitter Delay Compensation (TDC)
|
||||
*
|
||||
* Please refer to struct can_tdc_const and can_tdc in
|
||||
* include/linux/can/bittiming.h for further details.
|
||||
*/
|
||||
enum {
|
||||
IFLA_CAN_TDC_UNSPEC,
|
||||
IFLA_CAN_TDC_TDCV_MIN, /* u32 */
|
||||
IFLA_CAN_TDC_TDCV_MAX, /* u32 */
|
||||
IFLA_CAN_TDC_TDCO_MIN, /* u32 */
|
||||
IFLA_CAN_TDC_TDCO_MAX, /* u32 */
|
||||
IFLA_CAN_TDC_TDCF_MIN, /* u32 */
|
||||
IFLA_CAN_TDC_TDCF_MAX, /* u32 */
|
||||
IFLA_CAN_TDC_TDCV, /* u32 */
|
||||
IFLA_CAN_TDC_TDCO, /* u32 */
|
||||
IFLA_CAN_TDC_TDCF, /* u32 */
|
||||
|
||||
/* add new constants above here */
|
||||
__IFLA_CAN_TDC,
|
||||
IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1
|
||||
};
|
||||
#define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
|
||||
|
||||
/* u16 termination range: 1..65535 Ohms */
|
||||
#define CAN_TERMINATION_DISABLED 0
|
||||
|
|
|
|||
|
|
@ -28,9 +28,4 @@
|
|||
#define _BITUL(x) (_UL(1) << (x))
|
||||
#define _BITULL(x) (_ULL(1) << (x))
|
||||
|
||||
#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
|
||||
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
|
||||
|
||||
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||
|
||||
#endif /* _LINUX_CONST_H */
|
||||
|
|
|
|||
|
|
@ -1,769 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/*
|
||||
* Copyright (c) 2008-2011, Intel Corporation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
* Place - Suite 330, Boston, MA 02111-1307 USA.
|
||||
*
|
||||
* Author: Lucy Liu <lucy.liu@intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_DCBNL_H__
|
||||
#define __LINUX_DCBNL_H__
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* IEEE 802.1Qaz std supported values */
|
||||
#define IEEE_8021QAZ_MAX_TCS 8
|
||||
|
||||
#define IEEE_8021QAZ_TSA_STRICT 0
|
||||
#define IEEE_8021QAZ_TSA_CB_SHAPER 1
|
||||
#define IEEE_8021QAZ_TSA_ETS 2
|
||||
#define IEEE_8021QAZ_TSA_VENDOR 255
|
||||
|
||||
/* This structure contains the IEEE 802.1Qaz ETS managed object
|
||||
*
|
||||
* @willing: willing bit in ETS configuration TLV
|
||||
* @ets_cap: indicates supported capacity of ets feature
|
||||
* @cbs: credit based shaper ets algorithm supported
|
||||
* @tc_tx_bw: tc tx bandwidth indexed by traffic class
|
||||
* @tc_rx_bw: tc rx bandwidth indexed by traffic class
|
||||
* @tc_tsa: TSA Assignment table, indexed by traffic class
|
||||
* @prio_tc: priority assignment table mapping 8021Qp to traffic class
|
||||
* @tc_reco_bw: recommended tc bandwidth indexed by traffic class for TLV
|
||||
* @tc_reco_tsa: recommended tc bandwidth indexed by traffic class for TLV
|
||||
* @reco_prio_tc: recommended tc tx bandwidth indexed by traffic class for TLV
|
||||
*
|
||||
* Recommended values are used to set fields in the ETS recommendation TLV
|
||||
* with hardware offloaded LLDP.
|
||||
*
|
||||
* ----
|
||||
* TSA Assignment 8 bit identifiers
|
||||
* 0 strict priority
|
||||
* 1 credit-based shaper
|
||||
* 2 enhanced transmission selection
|
||||
* 3-254 reserved
|
||||
* 255 vendor specific
|
||||
*/
|
||||
struct ieee_ets {
|
||||
__u8 willing;
|
||||
__u8 ets_cap;
|
||||
__u8 cbs;
|
||||
__u8 tc_tx_bw[IEEE_8021QAZ_MAX_TCS];
|
||||
__u8 tc_rx_bw[IEEE_8021QAZ_MAX_TCS];
|
||||
__u8 tc_tsa[IEEE_8021QAZ_MAX_TCS];
|
||||
__u8 prio_tc[IEEE_8021QAZ_MAX_TCS];
|
||||
__u8 tc_reco_bw[IEEE_8021QAZ_MAX_TCS];
|
||||
__u8 tc_reco_tsa[IEEE_8021QAZ_MAX_TCS];
|
||||
__u8 reco_prio_tc[IEEE_8021QAZ_MAX_TCS];
|
||||
};
|
||||
|
||||
/* This structure contains rate limit extension to the IEEE 802.1Qaz ETS
|
||||
* managed object.
|
||||
* Values are 64 bits long and specified in Kbps to enable usage over both
|
||||
* slow and very fast networks.
|
||||
*
|
||||
* @tc_maxrate: maximal tc tx bandwidth indexed by traffic class
|
||||
*/
|
||||
struct ieee_maxrate {
|
||||
__u64 tc_maxrate[IEEE_8021QAZ_MAX_TCS];
|
||||
};
|
||||
|
||||
enum dcbnl_cndd_states {
|
||||
DCB_CNDD_RESET = 0,
|
||||
DCB_CNDD_EDGE,
|
||||
DCB_CNDD_INTERIOR,
|
||||
DCB_CNDD_INTERIOR_READY,
|
||||
};
|
||||
|
||||
/* This structure contains the IEEE 802.1Qau QCN managed object.
|
||||
*
|
||||
*@rpg_enable: enable QCN RP
|
||||
*@rppp_max_rps: maximum number of RPs allowed for this CNPV on this port
|
||||
*@rpg_time_reset: time between rate increases if no CNMs received.
|
||||
* given in u-seconds
|
||||
*@rpg_byte_reset: transmitted data between rate increases if no CNMs received.
|
||||
* given in Bytes
|
||||
*@rpg_threshold: The number of times rpByteStage or rpTimeStage can count
|
||||
* before RP rate control state machine advances states
|
||||
*@rpg_max_rate: the maxinun rate, in Mbits per second,
|
||||
* at which an RP can transmit
|
||||
*@rpg_ai_rate: The rate, in Mbits per second,
|
||||
* used to increase rpTargetRate in the RPR_ACTIVE_INCREASE
|
||||
*@rpg_hai_rate: The rate, in Mbits per second,
|
||||
* used to increase rpTargetRate in the RPR_HYPER_INCREASE state
|
||||
*@rpg_gd: Upon CNM receive, flow rate is limited to (Fb/Gd)*CurrentRate.
|
||||
* rpgGd is given as log2(Gd), where Gd may only be powers of 2
|
||||
*@rpg_min_dec_fac: The minimum factor by which the current transmit rate
|
||||
* can be changed by reception of a CNM.
|
||||
* value is given as percentage (1-100)
|
||||
*@rpg_min_rate: The minimum value, in bits per second, for rate to limit
|
||||
*@cndd_state_machine: The state of the congestion notification domain
|
||||
* defense state machine, as defined by IEEE 802.3Qau
|
||||
* section 32.1.1. In the interior ready state,
|
||||
* the QCN capable hardware may add CN-TAG TLV to the
|
||||
* outgoing traffic, to specifically identify outgoing
|
||||
* flows.
|
||||
*/
|
||||
|
||||
struct ieee_qcn {
|
||||
__u8 rpg_enable[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rppp_max_rps[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_time_reset[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_byte_reset[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_threshold[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_max_rate[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_ai_rate[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_hai_rate[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_gd[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_min_dec_fac[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rpg_min_rate[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 cndd_state_machine[IEEE_8021QAZ_MAX_TCS];
|
||||
};
|
||||
|
||||
/* This structure contains the IEEE 802.1Qau QCN statistics.
|
||||
*
|
||||
*@rppp_rp_centiseconds: the number of RP-centiseconds accumulated
|
||||
* by RPs at this priority level on this Port
|
||||
*@rppp_created_rps: number of active RPs(flows) that react to CNMs
|
||||
*/
|
||||
|
||||
struct ieee_qcn_stats {
|
||||
__u64 rppp_rp_centiseconds[IEEE_8021QAZ_MAX_TCS];
|
||||
__u32 rppp_created_rps[IEEE_8021QAZ_MAX_TCS];
|
||||
};
|
||||
|
||||
/* This structure contains the IEEE 802.1Qaz PFC managed object
|
||||
*
|
||||
* @pfc_cap: Indicates the number of traffic classes on the local device
|
||||
* that may simultaneously have PFC enabled.
|
||||
* @pfc_en: bitmap indicating pfc enabled traffic classes
|
||||
* @mbc: enable macsec bypass capability
|
||||
* @delay: the allowance made for a round-trip propagation delay of the
|
||||
* link in bits.
|
||||
* @requests: count of the sent pfc frames
|
||||
* @indications: count of the received pfc frames
|
||||
*/
|
||||
struct ieee_pfc {
|
||||
__u8 pfc_cap;
|
||||
__u8 pfc_en;
|
||||
__u8 mbc;
|
||||
__u16 delay;
|
||||
__u64 requests[IEEE_8021QAZ_MAX_TCS];
|
||||
__u64 indications[IEEE_8021QAZ_MAX_TCS];
|
||||
};
|
||||
|
||||
#define IEEE_8021Q_MAX_PRIORITIES 8
|
||||
#define DCBX_MAX_BUFFERS 8
|
||||
struct dcbnl_buffer {
|
||||
/* priority to buffer mapping */
|
||||
__u8 prio2buffer[IEEE_8021Q_MAX_PRIORITIES];
|
||||
/* buffer size in Bytes */
|
||||
__u32 buffer_size[DCBX_MAX_BUFFERS];
|
||||
__u32 total_size;
|
||||
};
|
||||
|
||||
/* CEE DCBX std supported values */
|
||||
#define CEE_DCBX_MAX_PGS 8
|
||||
#define CEE_DCBX_MAX_PRIO 8
|
||||
|
||||
/**
|
||||
* struct cee_pg - CEE Priority-Group managed object
|
||||
*
|
||||
* @willing: willing bit in the PG tlv
|
||||
* @error: error bit in the PG tlv
|
||||
* @pg_en: enable bit of the PG feature
|
||||
* @tcs_supported: number of traffic classes supported
|
||||
* @pg_bw: bandwidth percentage for each priority group
|
||||
* @prio_pg: priority to PG mapping indexed by priority
|
||||
*/
|
||||
struct cee_pg {
|
||||
__u8 willing;
|
||||
__u8 error;
|
||||
__u8 pg_en;
|
||||
__u8 tcs_supported;
|
||||
__u8 pg_bw[CEE_DCBX_MAX_PGS];
|
||||
__u8 prio_pg[CEE_DCBX_MAX_PGS];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct cee_pfc - CEE PFC managed object
|
||||
*
|
||||
* @willing: willing bit in the PFC tlv
|
||||
* @error: error bit in the PFC tlv
|
||||
* @pfc_en: bitmap indicating pfc enabled traffic classes
|
||||
* @tcs_supported: number of traffic classes supported
|
||||
*/
|
||||
struct cee_pfc {
|
||||
__u8 willing;
|
||||
__u8 error;
|
||||
__u8 pfc_en;
|
||||
__u8 tcs_supported;
|
||||
};
|
||||
|
||||
/* IEEE 802.1Qaz std supported values */
|
||||
#define IEEE_8021QAZ_APP_SEL_ETHERTYPE 1
|
||||
#define IEEE_8021QAZ_APP_SEL_STREAM 2
|
||||
#define IEEE_8021QAZ_APP_SEL_DGRAM 3
|
||||
#define IEEE_8021QAZ_APP_SEL_ANY 4
|
||||
#define IEEE_8021QAZ_APP_SEL_DSCP 5
|
||||
|
||||
/* This structure contains the IEEE 802.1Qaz APP managed object. This
|
||||
* object is also used for the CEE std as well.
|
||||
*
|
||||
* @selector: protocol identifier type
|
||||
* @protocol: protocol of type indicated
|
||||
* @priority: 3-bit unsigned integer indicating priority for IEEE
|
||||
* 8-bit 802.1p user priority bitmap for CEE
|
||||
*
|
||||
* ----
|
||||
* Selector field values for IEEE 802.1Qaz
|
||||
* 0 Reserved
|
||||
* 1 Ethertype
|
||||
* 2 Well known port number over TCP or SCTP
|
||||
* 3 Well known port number over UDP or DCCP
|
||||
* 4 Well known port number over TCP, SCTP, UDP, or DCCP
|
||||
* 5 Differentiated Services Code Point (DSCP) value
|
||||
* 6-7 Reserved
|
||||
*
|
||||
* Selector field values for CEE
|
||||
* 0 Ethertype
|
||||
* 1 Well known port number over TCP or UDP
|
||||
* 2-3 Reserved
|
||||
*/
|
||||
struct dcb_app {
|
||||
__u8 selector;
|
||||
__u8 priority;
|
||||
__u16 protocol;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct dcb_peer_app_info - APP feature information sent by the peer
|
||||
*
|
||||
* @willing: willing bit in the peer APP tlv
|
||||
* @error: error bit in the peer APP tlv
|
||||
*
|
||||
* In addition to this information the full peer APP tlv also contains
|
||||
* a table of 'app_count' APP objects defined above.
|
||||
*/
|
||||
struct dcb_peer_app_info {
|
||||
__u8 willing;
|
||||
__u8 error;
|
||||
};
|
||||
|
||||
struct dcbmsg {
|
||||
__u8 dcb_family;
|
||||
__u8 cmd;
|
||||
__u16 dcb_pad;
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dcbnl_commands - supported DCB commands
|
||||
*
|
||||
* @DCB_CMD_UNDEFINED: unspecified command to catch errors
|
||||
* @DCB_CMD_GSTATE: request the state of DCB in the device
|
||||
* @DCB_CMD_SSTATE: set the state of DCB in the device
|
||||
* @DCB_CMD_PGTX_GCFG: request the priority group configuration for Tx
|
||||
* @DCB_CMD_PGTX_SCFG: set the priority group configuration for Tx
|
||||
* @DCB_CMD_PGRX_GCFG: request the priority group configuration for Rx
|
||||
* @DCB_CMD_PGRX_SCFG: set the priority group configuration for Rx
|
||||
* @DCB_CMD_PFC_GCFG: request the priority flow control configuration
|
||||
* @DCB_CMD_PFC_SCFG: set the priority flow control configuration
|
||||
* @DCB_CMD_SET_ALL: apply all changes to the underlying device
|
||||
* @DCB_CMD_GPERM_HWADDR: get the permanent MAC address of the underlying
|
||||
* device. Only useful when using bonding.
|
||||
* @DCB_CMD_GCAP: request the DCB capabilities of the device
|
||||
* @DCB_CMD_GNUMTCS: get the number of traffic classes currently supported
|
||||
* @DCB_CMD_SNUMTCS: set the number of traffic classes
|
||||
* @DCB_CMD_GBCN: set backward congestion notification configuration
|
||||
* @DCB_CMD_SBCN: get backward congestion notification configuration.
|
||||
* @DCB_CMD_GAPP: get application protocol configuration
|
||||
* @DCB_CMD_SAPP: set application protocol configuration
|
||||
* @DCB_CMD_IEEE_SET: set IEEE 802.1Qaz configuration
|
||||
* @DCB_CMD_IEEE_GET: get IEEE 802.1Qaz configuration
|
||||
* @DCB_CMD_GDCBX: get DCBX engine configuration
|
||||
* @DCB_CMD_SDCBX: set DCBX engine configuration
|
||||
* @DCB_CMD_GFEATCFG: get DCBX features flags
|
||||
* @DCB_CMD_SFEATCFG: set DCBX features negotiation flags
|
||||
* @DCB_CMD_CEE_GET: get CEE aggregated configuration
|
||||
* @DCB_CMD_IEEE_DEL: delete IEEE 802.1Qaz configuration
|
||||
*/
|
||||
enum dcbnl_commands {
|
||||
DCB_CMD_UNDEFINED,
|
||||
|
||||
DCB_CMD_GSTATE,
|
||||
DCB_CMD_SSTATE,
|
||||
|
||||
DCB_CMD_PGTX_GCFG,
|
||||
DCB_CMD_PGTX_SCFG,
|
||||
DCB_CMD_PGRX_GCFG,
|
||||
DCB_CMD_PGRX_SCFG,
|
||||
|
||||
DCB_CMD_PFC_GCFG,
|
||||
DCB_CMD_PFC_SCFG,
|
||||
|
||||
DCB_CMD_SET_ALL,
|
||||
|
||||
DCB_CMD_GPERM_HWADDR,
|
||||
|
||||
DCB_CMD_GCAP,
|
||||
|
||||
DCB_CMD_GNUMTCS,
|
||||
DCB_CMD_SNUMTCS,
|
||||
|
||||
DCB_CMD_PFC_GSTATE,
|
||||
DCB_CMD_PFC_SSTATE,
|
||||
|
||||
DCB_CMD_BCN_GCFG,
|
||||
DCB_CMD_BCN_SCFG,
|
||||
|
||||
DCB_CMD_GAPP,
|
||||
DCB_CMD_SAPP,
|
||||
|
||||
DCB_CMD_IEEE_SET,
|
||||
DCB_CMD_IEEE_GET,
|
||||
|
||||
DCB_CMD_GDCBX,
|
||||
DCB_CMD_SDCBX,
|
||||
|
||||
DCB_CMD_GFEATCFG,
|
||||
DCB_CMD_SFEATCFG,
|
||||
|
||||
DCB_CMD_CEE_GET,
|
||||
DCB_CMD_IEEE_DEL,
|
||||
|
||||
__DCB_CMD_ENUM_MAX,
|
||||
DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dcbnl_attrs - DCB top-level netlink attributes
|
||||
*
|
||||
* @DCB_ATTR_UNDEFINED: unspecified attribute to catch errors
|
||||
* @DCB_ATTR_IFNAME: interface name of the underlying device (NLA_STRING)
|
||||
* @DCB_ATTR_STATE: enable state of DCB in the device (NLA_U8)
|
||||
* @DCB_ATTR_PFC_STATE: enable state of PFC in the device (NLA_U8)
|
||||
* @DCB_ATTR_PFC_CFG: priority flow control configuration (NLA_NESTED)
|
||||
* @DCB_ATTR_NUM_TC: number of traffic classes supported in the device (NLA_U8)
|
||||
* @DCB_ATTR_PG_CFG: priority group configuration (NLA_NESTED)
|
||||
* @DCB_ATTR_SET_ALL: bool to commit changes to hardware or not (NLA_U8)
|
||||
* @DCB_ATTR_PERM_HWADDR: MAC address of the physical device (NLA_NESTED)
|
||||
* @DCB_ATTR_CAP: DCB capabilities of the device (NLA_NESTED)
|
||||
* @DCB_ATTR_NUMTCS: number of traffic classes supported (NLA_NESTED)
|
||||
* @DCB_ATTR_BCN: backward congestion notification configuration (NLA_NESTED)
|
||||
* @DCB_ATTR_IEEE: IEEE 802.1Qaz supported attributes (NLA_NESTED)
|
||||
* @DCB_ATTR_DCBX: DCBX engine configuration in the device (NLA_U8)
|
||||
* @DCB_ATTR_FEATCFG: DCBX features flags (NLA_NESTED)
|
||||
* @DCB_ATTR_CEE: CEE std supported attributes (NLA_NESTED)
|
||||
*/
|
||||
enum dcbnl_attrs {
|
||||
DCB_ATTR_UNDEFINED,
|
||||
|
||||
DCB_ATTR_IFNAME,
|
||||
DCB_ATTR_STATE,
|
||||
DCB_ATTR_PFC_STATE,
|
||||
DCB_ATTR_PFC_CFG,
|
||||
DCB_ATTR_NUM_TC,
|
||||
DCB_ATTR_PG_CFG,
|
||||
DCB_ATTR_SET_ALL,
|
||||
DCB_ATTR_PERM_HWADDR,
|
||||
DCB_ATTR_CAP,
|
||||
DCB_ATTR_NUMTCS,
|
||||
DCB_ATTR_BCN,
|
||||
DCB_ATTR_APP,
|
||||
|
||||
/* IEEE std attributes */
|
||||
DCB_ATTR_IEEE,
|
||||
|
||||
DCB_ATTR_DCBX,
|
||||
DCB_ATTR_FEATCFG,
|
||||
|
||||
/* CEE nested attributes */
|
||||
DCB_ATTR_CEE,
|
||||
|
||||
__DCB_ATTR_ENUM_MAX,
|
||||
DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum ieee_attrs - IEEE 802.1Qaz get/set attributes
|
||||
*
|
||||
* @DCB_ATTR_IEEE_UNSPEC: unspecified
|
||||
* @DCB_ATTR_IEEE_ETS: negotiated ETS configuration
|
||||
* @DCB_ATTR_IEEE_PFC: negotiated PFC configuration
|
||||
* @DCB_ATTR_IEEE_APP_TABLE: negotiated APP configuration
|
||||
* @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only
|
||||
* @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only
|
||||
* @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only
|
||||
*/
|
||||
enum ieee_attrs {
|
||||
DCB_ATTR_IEEE_UNSPEC,
|
||||
DCB_ATTR_IEEE_ETS,
|
||||
DCB_ATTR_IEEE_PFC,
|
||||
DCB_ATTR_IEEE_APP_TABLE,
|
||||
DCB_ATTR_IEEE_PEER_ETS,
|
||||
DCB_ATTR_IEEE_PEER_PFC,
|
||||
DCB_ATTR_IEEE_PEER_APP,
|
||||
DCB_ATTR_IEEE_MAXRATE,
|
||||
DCB_ATTR_IEEE_QCN,
|
||||
DCB_ATTR_IEEE_QCN_STATS,
|
||||
DCB_ATTR_DCB_BUFFER,
|
||||
__DCB_ATTR_IEEE_MAX
|
||||
};
|
||||
#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
|
||||
|
||||
enum ieee_attrs_app {
|
||||
DCB_ATTR_IEEE_APP_UNSPEC,
|
||||
DCB_ATTR_IEEE_APP,
|
||||
__DCB_ATTR_IEEE_APP_MAX
|
||||
};
|
||||
#define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1)
|
||||
|
||||
/**
|
||||
* enum cee_attrs - CEE DCBX get attributes.
|
||||
*
|
||||
* @DCB_ATTR_CEE_UNSPEC: unspecified
|
||||
* @DCB_ATTR_CEE_PEER_PG: peer PG configuration - get only
|
||||
* @DCB_ATTR_CEE_PEER_PFC: peer PFC configuration - get only
|
||||
* @DCB_ATTR_CEE_PEER_APP_TABLE: peer APP tlv - get only
|
||||
* @DCB_ATTR_CEE_TX_PG: TX PG configuration (DCB_CMD_PGTX_GCFG)
|
||||
* @DCB_ATTR_CEE_RX_PG: RX PG configuration (DCB_CMD_PGRX_GCFG)
|
||||
* @DCB_ATTR_CEE_PFC: PFC configuration (DCB_CMD_PFC_GCFG)
|
||||
* @DCB_ATTR_CEE_APP_TABLE: APP configuration (multi DCB_CMD_GAPP)
|
||||
* @DCB_ATTR_CEE_FEAT: DCBX features flags (DCB_CMD_GFEATCFG)
|
||||
*
|
||||
* An aggregated collection of the cee std negotiated parameters.
|
||||
*/
|
||||
enum cee_attrs {
|
||||
DCB_ATTR_CEE_UNSPEC,
|
||||
DCB_ATTR_CEE_PEER_PG,
|
||||
DCB_ATTR_CEE_PEER_PFC,
|
||||
DCB_ATTR_CEE_PEER_APP_TABLE,
|
||||
DCB_ATTR_CEE_TX_PG,
|
||||
DCB_ATTR_CEE_RX_PG,
|
||||
DCB_ATTR_CEE_PFC,
|
||||
DCB_ATTR_CEE_APP_TABLE,
|
||||
DCB_ATTR_CEE_FEAT,
|
||||
__DCB_ATTR_CEE_MAX
|
||||
};
|
||||
#define DCB_ATTR_CEE_MAX (__DCB_ATTR_CEE_MAX - 1)
|
||||
|
||||
enum peer_app_attr {
|
||||
DCB_ATTR_CEE_PEER_APP_UNSPEC,
|
||||
DCB_ATTR_CEE_PEER_APP_INFO,
|
||||
DCB_ATTR_CEE_PEER_APP,
|
||||
__DCB_ATTR_CEE_PEER_APP_MAX
|
||||
};
|
||||
#define DCB_ATTR_CEE_PEER_APP_MAX (__DCB_ATTR_CEE_PEER_APP_MAX - 1)
|
||||
|
||||
enum cee_attrs_app {
|
||||
DCB_ATTR_CEE_APP_UNSPEC,
|
||||
DCB_ATTR_CEE_APP,
|
||||
__DCB_ATTR_CEE_APP_MAX
|
||||
};
|
||||
#define DCB_ATTR_CEE_APP_MAX (__DCB_ATTR_CEE_APP_MAX - 1)
|
||||
|
||||
/**
|
||||
* enum dcbnl_pfc_attrs - DCB Priority Flow Control user priority nested attrs
|
||||
*
|
||||
* @DCB_PFC_UP_ATTR_UNDEFINED: unspecified attribute to catch errors
|
||||
* @DCB_PFC_UP_ATTR_0: Priority Flow Control value for User Priority 0 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_1: Priority Flow Control value for User Priority 1 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_2: Priority Flow Control value for User Priority 2 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_3: Priority Flow Control value for User Priority 3 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_4: Priority Flow Control value for User Priority 4 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_5: Priority Flow Control value for User Priority 5 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_6: Priority Flow Control value for User Priority 6 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_7: Priority Flow Control value for User Priority 7 (NLA_U8)
|
||||
* @DCB_PFC_UP_ATTR_MAX: highest attribute number currently defined
|
||||
* @DCB_PFC_UP_ATTR_ALL: apply to all priority flow control attrs (NLA_FLAG)
|
||||
*
|
||||
*/
|
||||
enum dcbnl_pfc_up_attrs {
|
||||
DCB_PFC_UP_ATTR_UNDEFINED,
|
||||
|
||||
DCB_PFC_UP_ATTR_0,
|
||||
DCB_PFC_UP_ATTR_1,
|
||||
DCB_PFC_UP_ATTR_2,
|
||||
DCB_PFC_UP_ATTR_3,
|
||||
DCB_PFC_UP_ATTR_4,
|
||||
DCB_PFC_UP_ATTR_5,
|
||||
DCB_PFC_UP_ATTR_6,
|
||||
DCB_PFC_UP_ATTR_7,
|
||||
DCB_PFC_UP_ATTR_ALL,
|
||||
|
||||
__DCB_PFC_UP_ATTR_ENUM_MAX,
|
||||
DCB_PFC_UP_ATTR_MAX = __DCB_PFC_UP_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dcbnl_pg_attrs - DCB Priority Group attributes
|
||||
*
|
||||
* @DCB_PG_ATTR_UNDEFINED: unspecified attribute to catch errors
|
||||
* @DCB_PG_ATTR_TC_0: Priority Group Traffic Class 0 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_1: Priority Group Traffic Class 1 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_2: Priority Group Traffic Class 2 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_3: Priority Group Traffic Class 3 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_4: Priority Group Traffic Class 4 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_5: Priority Group Traffic Class 5 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_6: Priority Group Traffic Class 6 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_7: Priority Group Traffic Class 7 configuration (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_TC_MAX: highest attribute number currently defined
|
||||
* @DCB_PG_ATTR_TC_ALL: apply to all traffic classes (NLA_NESTED)
|
||||
* @DCB_PG_ATTR_BW_ID_0: Percent of link bandwidth for Priority Group 0 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_1: Percent of link bandwidth for Priority Group 1 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_2: Percent of link bandwidth for Priority Group 2 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_3: Percent of link bandwidth for Priority Group 3 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_4: Percent of link bandwidth for Priority Group 4 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_5: Percent of link bandwidth for Priority Group 5 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_6: Percent of link bandwidth for Priority Group 6 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_7: Percent of link bandwidth for Priority Group 7 (NLA_U8)
|
||||
* @DCB_PG_ATTR_BW_ID_MAX: highest attribute number currently defined
|
||||
* @DCB_PG_ATTR_BW_ID_ALL: apply to all priority groups (NLA_FLAG)
|
||||
*
|
||||
*/
|
||||
enum dcbnl_pg_attrs {
|
||||
DCB_PG_ATTR_UNDEFINED,
|
||||
|
||||
DCB_PG_ATTR_TC_0,
|
||||
DCB_PG_ATTR_TC_1,
|
||||
DCB_PG_ATTR_TC_2,
|
||||
DCB_PG_ATTR_TC_3,
|
||||
DCB_PG_ATTR_TC_4,
|
||||
DCB_PG_ATTR_TC_5,
|
||||
DCB_PG_ATTR_TC_6,
|
||||
DCB_PG_ATTR_TC_7,
|
||||
DCB_PG_ATTR_TC_MAX,
|
||||
DCB_PG_ATTR_TC_ALL,
|
||||
|
||||
DCB_PG_ATTR_BW_ID_0,
|
||||
DCB_PG_ATTR_BW_ID_1,
|
||||
DCB_PG_ATTR_BW_ID_2,
|
||||
DCB_PG_ATTR_BW_ID_3,
|
||||
DCB_PG_ATTR_BW_ID_4,
|
||||
DCB_PG_ATTR_BW_ID_5,
|
||||
DCB_PG_ATTR_BW_ID_6,
|
||||
DCB_PG_ATTR_BW_ID_7,
|
||||
DCB_PG_ATTR_BW_ID_MAX,
|
||||
DCB_PG_ATTR_BW_ID_ALL,
|
||||
|
||||
__DCB_PG_ATTR_ENUM_MAX,
|
||||
DCB_PG_ATTR_MAX = __DCB_PG_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dcbnl_tc_attrs - DCB Traffic Class attributes
|
||||
*
|
||||
* @DCB_TC_ATTR_PARAM_UNDEFINED: unspecified attribute to catch errors
|
||||
* @DCB_TC_ATTR_PARAM_PGID: (NLA_U8) Priority group the traffic class belongs to
|
||||
* Valid values are: 0-7
|
||||
* @DCB_TC_ATTR_PARAM_UP_MAPPING: (NLA_U8) Traffic class to user priority map
|
||||
* Some devices may not support changing the
|
||||
* user priority map of a TC.
|
||||
* @DCB_TC_ATTR_PARAM_STRICT_PRIO: (NLA_U8) Strict priority setting
|
||||
* 0 - none
|
||||
* 1 - group strict
|
||||
* 2 - link strict
|
||||
* @DCB_TC_ATTR_PARAM_BW_PCT: optional - (NLA_U8) If supported by the device and
|
||||
* not configured to use link strict priority,
|
||||
* this is the percentage of bandwidth of the
|
||||
* priority group this traffic class belongs to
|
||||
* @DCB_TC_ATTR_PARAM_ALL: (NLA_FLAG) all traffic class parameters
|
||||
*
|
||||
*/
|
||||
enum dcbnl_tc_attrs {
|
||||
DCB_TC_ATTR_PARAM_UNDEFINED,
|
||||
|
||||
DCB_TC_ATTR_PARAM_PGID,
|
||||
DCB_TC_ATTR_PARAM_UP_MAPPING,
|
||||
DCB_TC_ATTR_PARAM_STRICT_PRIO,
|
||||
DCB_TC_ATTR_PARAM_BW_PCT,
|
||||
DCB_TC_ATTR_PARAM_ALL,
|
||||
|
||||
__DCB_TC_ATTR_PARAM_ENUM_MAX,
|
||||
DCB_TC_ATTR_PARAM_MAX = __DCB_TC_ATTR_PARAM_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dcbnl_cap_attrs - DCB Capability attributes
|
||||
*
|
||||
* @DCB_CAP_ATTR_UNDEFINED: unspecified attribute to catch errors
|
||||
* @DCB_CAP_ATTR_ALL: (NLA_FLAG) all capability parameters
|
||||
* @DCB_CAP_ATTR_PG: (NLA_U8) device supports Priority Groups
|
||||
* @DCB_CAP_ATTR_PFC: (NLA_U8) device supports Priority Flow Control
|
||||
* @DCB_CAP_ATTR_UP2TC: (NLA_U8) device supports user priority to
|
||||
* traffic class mapping
|
||||
* @DCB_CAP_ATTR_PG_TCS: (NLA_U8) bitmap where each bit represents a
|
||||
* number of traffic classes the device
|
||||
* can be configured to use for Priority Groups
|
||||
* @DCB_CAP_ATTR_PFC_TCS: (NLA_U8) bitmap where each bit represents a
|
||||
* number of traffic classes the device can be
|
||||
* configured to use for Priority Flow Control
|
||||
* @DCB_CAP_ATTR_GSP: (NLA_U8) device supports group strict priority
|
||||
* @DCB_CAP_ATTR_BCN: (NLA_U8) device supports Backwards Congestion
|
||||
* Notification
|
||||
* @DCB_CAP_ATTR_DCBX: (NLA_U8) device supports DCBX engine
|
||||
*
|
||||
*/
|
||||
enum dcbnl_cap_attrs {
|
||||
DCB_CAP_ATTR_UNDEFINED,
|
||||
DCB_CAP_ATTR_ALL,
|
||||
DCB_CAP_ATTR_PG,
|
||||
DCB_CAP_ATTR_PFC,
|
||||
DCB_CAP_ATTR_UP2TC,
|
||||
DCB_CAP_ATTR_PG_TCS,
|
||||
DCB_CAP_ATTR_PFC_TCS,
|
||||
DCB_CAP_ATTR_GSP,
|
||||
DCB_CAP_ATTR_BCN,
|
||||
DCB_CAP_ATTR_DCBX,
|
||||
|
||||
__DCB_CAP_ATTR_ENUM_MAX,
|
||||
DCB_CAP_ATTR_MAX = __DCB_CAP_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* DCBX capability flags
|
||||
*
|
||||
* @DCB_CAP_DCBX_HOST: DCBX negotiation is performed by the host LLDP agent.
|
||||
* 'set' routines are used to configure the device with
|
||||
* the negotiated parameters
|
||||
*
|
||||
* @DCB_CAP_DCBX_LLD_MANAGED: DCBX negotiation is not performed in the host but
|
||||
* by another entity
|
||||
* 'get' routines are used to retrieve the
|
||||
* negotiated parameters
|
||||
* 'set' routines can be used to set the initial
|
||||
* negotiation configuration
|
||||
*
|
||||
* @DCB_CAP_DCBX_VER_CEE: for a non-host DCBX engine, indicates the engine
|
||||
* supports the CEE protocol flavor
|
||||
*
|
||||
* @DCB_CAP_DCBX_VER_IEEE: for a non-host DCBX engine, indicates the engine
|
||||
* supports the IEEE protocol flavor
|
||||
*
|
||||
* @DCB_CAP_DCBX_STATIC: for a non-host DCBX engine, indicates the engine
|
||||
* supports static configuration (i.e no actual
|
||||
* negotiation is performed negotiated parameters equal
|
||||
* the initial configuration)
|
||||
*
|
||||
*/
|
||||
#define DCB_CAP_DCBX_HOST 0x01
|
||||
#define DCB_CAP_DCBX_LLD_MANAGED 0x02
|
||||
#define DCB_CAP_DCBX_VER_CEE 0x04
|
||||
#define DCB_CAP_DCBX_VER_IEEE 0x08
|
||||
#define DCB_CAP_DCBX_STATIC 0x10
|
||||
|
||||
/**
|
||||
* enum dcbnl_numtcs_attrs - number of traffic classes
|
||||
*
|
||||
* @DCB_NUMTCS_ATTR_UNDEFINED: unspecified attribute to catch errors
|
||||
* @DCB_NUMTCS_ATTR_ALL: (NLA_FLAG) all traffic class attributes
|
||||
* @DCB_NUMTCS_ATTR_PG: (NLA_U8) number of traffic classes used for
|
||||
* priority groups
|
||||
* @DCB_NUMTCS_ATTR_PFC: (NLA_U8) number of traffic classes which can
|
||||
* support priority flow control
|
||||
*/
|
||||
enum dcbnl_numtcs_attrs {
|
||||
DCB_NUMTCS_ATTR_UNDEFINED,
|
||||
DCB_NUMTCS_ATTR_ALL,
|
||||
DCB_NUMTCS_ATTR_PG,
|
||||
DCB_NUMTCS_ATTR_PFC,
|
||||
|
||||
__DCB_NUMTCS_ATTR_ENUM_MAX,
|
||||
DCB_NUMTCS_ATTR_MAX = __DCB_NUMTCS_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
enum dcbnl_bcn_attrs{
|
||||
DCB_BCN_ATTR_UNDEFINED = 0,
|
||||
|
||||
DCB_BCN_ATTR_RP_0,
|
||||
DCB_BCN_ATTR_RP_1,
|
||||
DCB_BCN_ATTR_RP_2,
|
||||
DCB_BCN_ATTR_RP_3,
|
||||
DCB_BCN_ATTR_RP_4,
|
||||
DCB_BCN_ATTR_RP_5,
|
||||
DCB_BCN_ATTR_RP_6,
|
||||
DCB_BCN_ATTR_RP_7,
|
||||
DCB_BCN_ATTR_RP_ALL,
|
||||
|
||||
DCB_BCN_ATTR_BCNA_0,
|
||||
DCB_BCN_ATTR_BCNA_1,
|
||||
DCB_BCN_ATTR_ALPHA,
|
||||
DCB_BCN_ATTR_BETA,
|
||||
DCB_BCN_ATTR_GD,
|
||||
DCB_BCN_ATTR_GI,
|
||||
DCB_BCN_ATTR_TMAX,
|
||||
DCB_BCN_ATTR_TD,
|
||||
DCB_BCN_ATTR_RMIN,
|
||||
DCB_BCN_ATTR_W,
|
||||
DCB_BCN_ATTR_RD,
|
||||
DCB_BCN_ATTR_RU,
|
||||
DCB_BCN_ATTR_WRTT,
|
||||
DCB_BCN_ATTR_RI,
|
||||
DCB_BCN_ATTR_C,
|
||||
DCB_BCN_ATTR_ALL,
|
||||
|
||||
__DCB_BCN_ATTR_ENUM_MAX,
|
||||
DCB_BCN_ATTR_MAX = __DCB_BCN_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dcb_general_attr_values - general DCB attribute values
|
||||
*
|
||||
* @DCB_ATTR_UNDEFINED: value used to indicate an attribute is not supported
|
||||
*
|
||||
*/
|
||||
enum dcb_general_attr_values {
|
||||
DCB_ATTR_VALUE_UNDEFINED = 0xff
|
||||
};
|
||||
|
||||
#define DCB_APP_IDTYPE_ETHTYPE 0x00
|
||||
#define DCB_APP_IDTYPE_PORTNUM 0x01
|
||||
enum dcbnl_app_attrs {
|
||||
DCB_APP_ATTR_UNDEFINED,
|
||||
|
||||
DCB_APP_ATTR_IDTYPE,
|
||||
DCB_APP_ATTR_ID,
|
||||
DCB_APP_ATTR_PRIORITY,
|
||||
|
||||
__DCB_APP_ATTR_ENUM_MAX,
|
||||
DCB_APP_ATTR_MAX = __DCB_APP_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dcbnl_featcfg_attrs - features conifiguration flags
|
||||
*
|
||||
* @DCB_FEATCFG_ATTR_UNDEFINED: unspecified attribute to catch errors
|
||||
* @DCB_FEATCFG_ATTR_ALL: (NLA_FLAG) all features configuration attributes
|
||||
* @DCB_FEATCFG_ATTR_PG: (NLA_U8) configuration flags for priority groups
|
||||
* @DCB_FEATCFG_ATTR_PFC: (NLA_U8) configuration flags for priority
|
||||
* flow control
|
||||
* @DCB_FEATCFG_ATTR_APP: (NLA_U8) configuration flags for application TLV
|
||||
*
|
||||
*/
|
||||
#define DCB_FEATCFG_ERROR 0x01 /* error in feature resolution */
|
||||
#define DCB_FEATCFG_ENABLE 0x02 /* enable feature */
|
||||
#define DCB_FEATCFG_WILLING 0x04 /* feature is willing */
|
||||
#define DCB_FEATCFG_ADVERTISE 0x08 /* advertise feature */
|
||||
enum dcbnl_featcfg_attrs {
|
||||
DCB_FEATCFG_ATTR_UNDEFINED,
|
||||
DCB_FEATCFG_ATTR_ALL,
|
||||
DCB_FEATCFG_ATTR_PG,
|
||||
DCB_FEATCFG_ATTR_PFC,
|
||||
DCB_FEATCFG_ATTR_APP,
|
||||
|
||||
__DCB_FEATCFG_ATTR_ENUM_MAX,
|
||||
DCB_FEATCFG_ATTR_MAX = __DCB_FEATCFG_ATTR_ENUM_MAX - 1,
|
||||
};
|
||||
|
||||
#endif /* __LINUX_DCBNL_H__ */
|
||||
|
|
@ -13,8 +13,6 @@
|
|||
#ifndef _LINUX_DEVLINK_H_
|
||||
#define _LINUX_DEVLINK_H_
|
||||
|
||||
#include <linux/const.h>
|
||||
|
||||
#define DEVLINK_GENL_NAME "devlink"
|
||||
#define DEVLINK_GENL_VERSION 0x1
|
||||
#define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
|
||||
|
|
@ -124,13 +122,6 @@ enum devlink_command {
|
|||
DEVLINK_CMD_TRAP_POLICER_NEW,
|
||||
DEVLINK_CMD_TRAP_POLICER_DEL,
|
||||
|
||||
DEVLINK_CMD_HEALTH_REPORTER_TEST,
|
||||
|
||||
DEVLINK_CMD_RATE_GET, /* can dump */
|
||||
DEVLINK_CMD_RATE_SET,
|
||||
DEVLINK_CMD_RATE_NEW,
|
||||
DEVLINK_CMD_RATE_DEL,
|
||||
|
||||
/* add new commands above here */
|
||||
__DEVLINK_CMD_MAX,
|
||||
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
|
||||
|
|
@ -202,18 +193,6 @@ enum devlink_port_flavour {
|
|||
* port that faces the PCI VF.
|
||||
*/
|
||||
DEVLINK_PORT_FLAVOUR_VIRTUAL, /* Any virtual port facing the user. */
|
||||
DEVLINK_PORT_FLAVOUR_UNUSED, /* Port which exists in the switch, but
|
||||
* is not used in any way.
|
||||
*/
|
||||
DEVLINK_PORT_FLAVOUR_PCI_SF, /* Represents eswitch port
|
||||
* for the PCI SF. It is an internal
|
||||
* port that faces the PCI SF.
|
||||
*/
|
||||
};
|
||||
|
||||
enum devlink_rate_type {
|
||||
DEVLINK_RATE_TYPE_LEAF,
|
||||
DEVLINK_RATE_TYPE_NODE,
|
||||
};
|
||||
|
||||
enum devlink_param_cmode {
|
||||
|
|
@ -249,40 +228,15 @@ enum {
|
|||
DEVLINK_ATTR_STATS_MAX = __DEVLINK_ATTR_STATS_MAX - 1
|
||||
};
|
||||
|
||||
/* Specify what sections of a flash component can be overwritten when
|
||||
* performing an update. Overwriting of firmware binary sections is always
|
||||
* implicitly assumed to be allowed.
|
||||
*
|
||||
* Each section must be documented in
|
||||
* Documentation/networking/devlink/devlink-flash.rst
|
||||
*
|
||||
*/
|
||||
enum {
|
||||
DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT,
|
||||
DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT,
|
||||
|
||||
__DEVLINK_FLASH_OVERWRITE_MAX_BIT,
|
||||
DEVLINK_FLASH_OVERWRITE_MAX_BIT = __DEVLINK_FLASH_OVERWRITE_MAX_BIT - 1
|
||||
};
|
||||
|
||||
#define DEVLINK_FLASH_OVERWRITE_SETTINGS _BITUL(DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT)
|
||||
#define DEVLINK_FLASH_OVERWRITE_IDENTIFIERS _BITUL(DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT)
|
||||
|
||||
#define DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS \
|
||||
(_BITUL(__DEVLINK_FLASH_OVERWRITE_MAX_BIT) - 1)
|
||||
|
||||
/**
|
||||
* enum devlink_trap_action - Packet trap action.
|
||||
* @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not
|
||||
* sent to the CPU.
|
||||
* @DEVLINK_TRAP_ACTION_TRAP: The sole copy of the packet is sent to the CPU.
|
||||
* @DEVLINK_TRAP_ACTION_MIRROR: Packet is forwarded by the device and a copy is
|
||||
* sent to the CPU.
|
||||
*/
|
||||
enum devlink_trap_action {
|
||||
DEVLINK_TRAP_ACTION_DROP,
|
||||
DEVLINK_TRAP_ACTION_TRAP,
|
||||
DEVLINK_TRAP_ACTION_MIRROR,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -296,16 +250,10 @@ enum devlink_trap_action {
|
|||
* control plane for resolution. Trapped packets
|
||||
* are processed by devlink and injected to
|
||||
* the kernel's Rx path.
|
||||
* @DEVLINK_TRAP_TYPE_CONTROL: Packet was trapped because it is required for
|
||||
* the correct functioning of the control plane.
|
||||
* For example, an ARP request packet. Trapped
|
||||
* packets are injected to the kernel's Rx path,
|
||||
* but not reported to drop monitor.
|
||||
*/
|
||||
enum devlink_trap_type {
|
||||
DEVLINK_TRAP_TYPE_DROP,
|
||||
DEVLINK_TRAP_TYPE_EXCEPTION,
|
||||
DEVLINK_TRAP_TYPE_CONTROL,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -315,29 +263,6 @@ enum {
|
|||
DEVLINK_ATTR_TRAP_METADATA_TYPE_FA_COOKIE,
|
||||
};
|
||||
|
||||
enum devlink_reload_action {
|
||||
DEVLINK_RELOAD_ACTION_UNSPEC,
|
||||
DEVLINK_RELOAD_ACTION_DRIVER_REINIT, /* Driver entities re-instantiation */
|
||||
DEVLINK_RELOAD_ACTION_FW_ACTIVATE, /* FW activate */
|
||||
|
||||
/* Add new reload actions above */
|
||||
__DEVLINK_RELOAD_ACTION_MAX,
|
||||
DEVLINK_RELOAD_ACTION_MAX = __DEVLINK_RELOAD_ACTION_MAX - 1
|
||||
};
|
||||
|
||||
enum devlink_reload_limit {
|
||||
DEVLINK_RELOAD_LIMIT_UNSPEC, /* unspecified, no constraints */
|
||||
DEVLINK_RELOAD_LIMIT_NO_RESET, /* No reset allowed, no down time allowed,
|
||||
* no link flap and no configuration is lost.
|
||||
*/
|
||||
|
||||
/* Add new reload limit above */
|
||||
__DEVLINK_RELOAD_LIMIT_MAX,
|
||||
DEVLINK_RELOAD_LIMIT_MAX = __DEVLINK_RELOAD_LIMIT_MAX - 1
|
||||
};
|
||||
|
||||
#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
|
||||
|
||||
enum devlink_attr {
|
||||
/* don't change the order or add anything between, this is ABI! */
|
||||
DEVLINK_ATTR_UNSPEC,
|
||||
|
|
@ -517,42 +442,6 @@ enum devlink_attr {
|
|||
DEVLINK_ATTR_TRAP_POLICER_RATE, /* u64 */
|
||||
DEVLINK_ATTR_TRAP_POLICER_BURST, /* u64 */
|
||||
|
||||
DEVLINK_ATTR_PORT_FUNCTION, /* nested */
|
||||
|
||||
DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER, /* string */
|
||||
|
||||
DEVLINK_ATTR_PORT_LANES, /* u32 */
|
||||
DEVLINK_ATTR_PORT_SPLITTABLE, /* u8 */
|
||||
|
||||
DEVLINK_ATTR_PORT_EXTERNAL, /* u8 */
|
||||
DEVLINK_ATTR_PORT_CONTROLLER_NUMBER, /* u32 */
|
||||
|
||||
DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT, /* u64 */
|
||||
DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK, /* bitfield32 */
|
||||
|
||||
DEVLINK_ATTR_RELOAD_ACTION, /* u8 */
|
||||
DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED, /* bitfield32 */
|
||||
DEVLINK_ATTR_RELOAD_LIMITS, /* bitfield32 */
|
||||
|
||||
DEVLINK_ATTR_DEV_STATS, /* nested */
|
||||
DEVLINK_ATTR_RELOAD_STATS, /* nested */
|
||||
DEVLINK_ATTR_RELOAD_STATS_ENTRY, /* nested */
|
||||
DEVLINK_ATTR_RELOAD_STATS_LIMIT, /* u8 */
|
||||
DEVLINK_ATTR_RELOAD_STATS_VALUE, /* u32 */
|
||||
DEVLINK_ATTR_REMOTE_RELOAD_STATS, /* nested */
|
||||
DEVLINK_ATTR_RELOAD_ACTION_INFO, /* nested */
|
||||
DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */
|
||||
|
||||
DEVLINK_ATTR_PORT_PCI_SF_NUMBER, /* u32 */
|
||||
|
||||
DEVLINK_ATTR_RATE_TYPE, /* u16 */
|
||||
DEVLINK_ATTR_RATE_TX_SHARE, /* u64 */
|
||||
DEVLINK_ATTR_RATE_TX_MAX, /* u64 */
|
||||
DEVLINK_ATTR_RATE_NODE_NAME, /* string */
|
||||
DEVLINK_ATTR_RATE_PARENT_NODE_NAME, /* string */
|
||||
|
||||
DEVLINK_ATTR_REGION_MAX_SNAPSHOTS, /* u32 */
|
||||
|
||||
/* add new attributes above here, update the policy in devlink.c */
|
||||
|
||||
__DEVLINK_ATTR_MAX,
|
||||
|
|
@ -599,32 +488,4 @@ enum devlink_resource_unit {
|
|||
DEVLINK_RESOURCE_UNIT_ENTRY,
|
||||
};
|
||||
|
||||
enum devlink_port_function_attr {
|
||||
DEVLINK_PORT_FUNCTION_ATTR_UNSPEC,
|
||||
DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR, /* binary */
|
||||
DEVLINK_PORT_FN_ATTR_STATE, /* u8 */
|
||||
DEVLINK_PORT_FN_ATTR_OPSTATE, /* u8 */
|
||||
|
||||
__DEVLINK_PORT_FUNCTION_ATTR_MAX,
|
||||
DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1
|
||||
};
|
||||
|
||||
enum devlink_port_fn_state {
|
||||
DEVLINK_PORT_FN_STATE_INACTIVE,
|
||||
DEVLINK_PORT_FN_STATE_ACTIVE,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum devlink_port_fn_opstate - indicates operational state of the function
|
||||
* @DEVLINK_PORT_FN_OPSTATE_ATTACHED: Driver is attached to the function.
|
||||
* For graceful tear down of the function, after inactivation of the
|
||||
* function, user should wait for operational state to turn DETACHED.
|
||||
* @DEVLINK_PORT_FN_OPSTATE_DETACHED: Driver is detached from the function.
|
||||
* It is safe to delete the port.
|
||||
*/
|
||||
enum devlink_port_fn_opstate {
|
||||
DEVLINK_PORT_FN_OPSTATE_DETACHED,
|
||||
DEVLINK_PORT_FN_OPSTATE_ATTACHED,
|
||||
};
|
||||
|
||||
#endif /* _LINUX_DEVLINK_H_ */
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ enum {
|
|||
CTRL_CMD_NEWMCAST_GRP,
|
||||
CTRL_CMD_DELMCAST_GRP,
|
||||
CTRL_CMD_GETMCAST_GRP, /* unused */
|
||||
CTRL_CMD_GETPOLICY,
|
||||
__CTRL_CMD_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -63,9 +62,6 @@ enum {
|
|||
CTRL_ATTR_MAXATTR,
|
||||
CTRL_ATTR_OPS,
|
||||
CTRL_ATTR_MCAST_GROUPS,
|
||||
CTRL_ATTR_POLICY,
|
||||
CTRL_ATTR_OP_POLICY,
|
||||
CTRL_ATTR_OP,
|
||||
__CTRL_ATTR_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -87,15 +83,6 @@ enum {
|
|||
__CTRL_ATTR_MCAST_GRP_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
CTRL_ATTR_POLICY_UNSPEC,
|
||||
CTRL_ATTR_POLICY_DO,
|
||||
CTRL_ATTR_POLICY_DUMP,
|
||||
|
||||
__CTRL_ATTR_POLICY_DUMP_MAX,
|
||||
CTRL_ATTR_POLICY_DUMP_MAX = __CTRL_ATTR_POLICY_DUMP_MAX - 1
|
||||
};
|
||||
|
||||
#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ struct icmp6hdr {
|
|||
#define icmp6_mtu icmp6_dataun.un_data32[0]
|
||||
#define icmp6_unused icmp6_dataun.un_data32[0]
|
||||
#define icmp6_maxdelay icmp6_dataun.un_data16[0]
|
||||
#define icmp6_datagram_len icmp6_dataun.un_data8[0]
|
||||
#define icmp6_router icmp6_dataun.u_nd_advt.router
|
||||
#define icmp6_solicited icmp6_dataun.u_nd_advt.solicited
|
||||
#define icmp6_override icmp6_dataun.u_nd_advt.override
|
||||
|
|
@ -138,11 +137,7 @@ struct icmp6hdr {
|
|||
#define ICMPV6_HDR_FIELD 0
|
||||
#define ICMPV6_UNK_NEXTHDR 1
|
||||
#define ICMPV6_UNK_OPTION 2
|
||||
#define ICMPV6_HDR_INCOMP 3
|
||||
|
||||
/* Codes for EXT_ECHO (PROBE) */
|
||||
#define ICMPV6_EXT_ECHO_REQUEST 160
|
||||
#define ICMPV6_EXT_ECHO_REPLY 161
|
||||
/*
|
||||
* constants for (set|get)sockopt
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ enum {
|
|||
enum {
|
||||
IF_LINK_MODE_DEFAULT,
|
||||
IF_LINK_MODE_DORMANT, /* limit upward transition to dormant */
|
||||
IF_LINK_MODE_TESTING, /* limit upward transition to testing */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -24,22 +24,6 @@ struct sockaddr_alg {
|
|||
__u8 salg_name[64];
|
||||
};
|
||||
|
||||
/*
|
||||
* Linux v4.12 and later removed the 64-byte limit on salg_name[]; it's now an
|
||||
* arbitrary-length field. We had to keep the original struct above for source
|
||||
* compatibility with existing userspace programs, though. Use the new struct
|
||||
* below if support for very long algorithm names is needed. To do this,
|
||||
* allocate 'sizeof(struct sockaddr_alg_new) + strlen(algname) + 1' bytes, and
|
||||
* copy algname (including the null terminator) into salg_name.
|
||||
*/
|
||||
struct sockaddr_alg_new {
|
||||
__u16 salg_family;
|
||||
__u8 salg_type[14];
|
||||
__u32 salg_feat;
|
||||
__u32 salg_mask;
|
||||
__u8 salg_name[];
|
||||
};
|
||||
|
||||
struct af_alg_iv {
|
||||
__u32 ivlen;
|
||||
__u8 iv[0];
|
||||
|
|
@ -51,7 +35,6 @@ struct af_alg_iv {
|
|||
#define ALG_SET_OP 3
|
||||
#define ALG_SET_AEAD_ASSOCLEN 4
|
||||
#define ALG_SET_AEAD_AUTHSIZE 5
|
||||
#define ALG_SET_DRBG_ENTROPY 6
|
||||
|
||||
/* Operations */
|
||||
#define ALG_OP_DECRYPT 0
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
#define ARPHRD_X25 271 /* CCITT X.25 */
|
||||
#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */
|
||||
#define ARPHRD_CAN 280 /* Controller Area Network */
|
||||
#define ARPHRD_MCTP 290
|
||||
#define ARPHRD_PPP 512
|
||||
#define ARPHRD_CISCO 513 /* Cisco HDLC */
|
||||
#define ARPHRD_HDLC ARPHRD_CISCO
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@
|
|||
#define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */
|
||||
#define BOND_XMIT_POLICY_ENCAP23 3 /* encapsulated layer 2+3 */
|
||||
#define BOND_XMIT_POLICY_ENCAP34 4 /* encapsulated layer 3+4 */
|
||||
#define BOND_XMIT_POLICY_VLAN_SRCMAC 5 /* vlan + source MAC */
|
||||
|
||||
/* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */
|
||||
#define LACP_STATE_LACP_ACTIVITY 0x1
|
||||
|
|
@ -153,3 +152,14 @@ enum {
|
|||
#define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
|
||||
|
||||
#endif /* _LINUX_IF_BONDING_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* version-control: t
|
||||
* kept-new-versions: 5
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* End:
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -120,8 +120,6 @@ enum {
|
|||
IFLA_BRIDGE_MODE,
|
||||
IFLA_BRIDGE_VLAN_INFO,
|
||||
IFLA_BRIDGE_VLAN_TUNNEL_INFO,
|
||||
IFLA_BRIDGE_MRP,
|
||||
IFLA_BRIDGE_CFM,
|
||||
__IFLA_BRIDGE_MAX,
|
||||
};
|
||||
#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
|
||||
|
|
@ -159,300 +157,6 @@ struct bridge_vlan_xstats {
|
|||
__u32 pad2;
|
||||
};
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_INSTANCE,
|
||||
IFLA_BRIDGE_MRP_PORT_STATE,
|
||||
IFLA_BRIDGE_MRP_PORT_ROLE,
|
||||
IFLA_BRIDGE_MRP_RING_STATE,
|
||||
IFLA_BRIDGE_MRP_RING_ROLE,
|
||||
IFLA_BRIDGE_MRP_START_TEST,
|
||||
IFLA_BRIDGE_MRP_INFO,
|
||||
IFLA_BRIDGE_MRP_IN_ROLE,
|
||||
IFLA_BRIDGE_MRP_IN_STATE,
|
||||
IFLA_BRIDGE_MRP_START_IN_TEST,
|
||||
__IFLA_BRIDGE_MRP_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_MAX (__IFLA_BRIDGE_MRP_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_INSTANCE_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_INSTANCE_RING_ID,
|
||||
IFLA_BRIDGE_MRP_INSTANCE_P_IFINDEX,
|
||||
IFLA_BRIDGE_MRP_INSTANCE_S_IFINDEX,
|
||||
IFLA_BRIDGE_MRP_INSTANCE_PRIO,
|
||||
__IFLA_BRIDGE_MRP_INSTANCE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_INSTANCE_MAX (__IFLA_BRIDGE_MRP_INSTANCE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_PORT_STATE_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_PORT_STATE_STATE,
|
||||
__IFLA_BRIDGE_MRP_PORT_STATE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_PORT_STATE_MAX (__IFLA_BRIDGE_MRP_PORT_STATE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_PORT_ROLE_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_PORT_ROLE_ROLE,
|
||||
__IFLA_BRIDGE_MRP_PORT_ROLE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_PORT_ROLE_MAX (__IFLA_BRIDGE_MRP_PORT_ROLE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_RING_STATE_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_RING_STATE_RING_ID,
|
||||
IFLA_BRIDGE_MRP_RING_STATE_STATE,
|
||||
__IFLA_BRIDGE_MRP_RING_STATE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_RING_STATE_MAX (__IFLA_BRIDGE_MRP_RING_STATE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_RING_ROLE_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_RING_ROLE_RING_ID,
|
||||
IFLA_BRIDGE_MRP_RING_ROLE_ROLE,
|
||||
__IFLA_BRIDGE_MRP_RING_ROLE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_RING_ROLE_MAX (__IFLA_BRIDGE_MRP_RING_ROLE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_START_TEST_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_START_TEST_RING_ID,
|
||||
IFLA_BRIDGE_MRP_START_TEST_INTERVAL,
|
||||
IFLA_BRIDGE_MRP_START_TEST_MAX_MISS,
|
||||
IFLA_BRIDGE_MRP_START_TEST_PERIOD,
|
||||
IFLA_BRIDGE_MRP_START_TEST_MONITOR,
|
||||
__IFLA_BRIDGE_MRP_START_TEST_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_START_TEST_MAX (__IFLA_BRIDGE_MRP_START_TEST_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_INFO_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_INFO_RING_ID,
|
||||
IFLA_BRIDGE_MRP_INFO_P_IFINDEX,
|
||||
IFLA_BRIDGE_MRP_INFO_S_IFINDEX,
|
||||
IFLA_BRIDGE_MRP_INFO_PRIO,
|
||||
IFLA_BRIDGE_MRP_INFO_RING_STATE,
|
||||
IFLA_BRIDGE_MRP_INFO_RING_ROLE,
|
||||
IFLA_BRIDGE_MRP_INFO_TEST_INTERVAL,
|
||||
IFLA_BRIDGE_MRP_INFO_TEST_MAX_MISS,
|
||||
IFLA_BRIDGE_MRP_INFO_TEST_MONITOR,
|
||||
IFLA_BRIDGE_MRP_INFO_I_IFINDEX,
|
||||
IFLA_BRIDGE_MRP_INFO_IN_STATE,
|
||||
IFLA_BRIDGE_MRP_INFO_IN_ROLE,
|
||||
IFLA_BRIDGE_MRP_INFO_IN_TEST_INTERVAL,
|
||||
IFLA_BRIDGE_MRP_INFO_IN_TEST_MAX_MISS,
|
||||
__IFLA_BRIDGE_MRP_INFO_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_INFO_MAX (__IFLA_BRIDGE_MRP_INFO_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_IN_STATE_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_IN_STATE_IN_ID,
|
||||
IFLA_BRIDGE_MRP_IN_STATE_STATE,
|
||||
__IFLA_BRIDGE_MRP_IN_STATE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_IN_STATE_MAX (__IFLA_BRIDGE_MRP_IN_STATE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_IN_ROLE_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_IN_ROLE_RING_ID,
|
||||
IFLA_BRIDGE_MRP_IN_ROLE_IN_ID,
|
||||
IFLA_BRIDGE_MRP_IN_ROLE_ROLE,
|
||||
IFLA_BRIDGE_MRP_IN_ROLE_I_IFINDEX,
|
||||
__IFLA_BRIDGE_MRP_IN_ROLE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_IN_ROLE_MAX (__IFLA_BRIDGE_MRP_IN_ROLE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_MRP_START_IN_TEST_UNSPEC,
|
||||
IFLA_BRIDGE_MRP_START_IN_TEST_IN_ID,
|
||||
IFLA_BRIDGE_MRP_START_IN_TEST_INTERVAL,
|
||||
IFLA_BRIDGE_MRP_START_IN_TEST_MAX_MISS,
|
||||
IFLA_BRIDGE_MRP_START_IN_TEST_PERIOD,
|
||||
__IFLA_BRIDGE_MRP_START_IN_TEST_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_MRP_START_IN_TEST_MAX (__IFLA_BRIDGE_MRP_START_IN_TEST_MAX - 1)
|
||||
|
||||
struct br_mrp_instance {
|
||||
__u32 ring_id;
|
||||
__u32 p_ifindex;
|
||||
__u32 s_ifindex;
|
||||
__u16 prio;
|
||||
};
|
||||
|
||||
struct br_mrp_ring_state {
|
||||
__u32 ring_id;
|
||||
__u32 ring_state;
|
||||
};
|
||||
|
||||
struct br_mrp_ring_role {
|
||||
__u32 ring_id;
|
||||
__u32 ring_role;
|
||||
};
|
||||
|
||||
struct br_mrp_start_test {
|
||||
__u32 ring_id;
|
||||
__u32 interval;
|
||||
__u32 max_miss;
|
||||
__u32 period;
|
||||
__u32 monitor;
|
||||
};
|
||||
|
||||
struct br_mrp_in_state {
|
||||
__u32 in_state;
|
||||
__u16 in_id;
|
||||
};
|
||||
|
||||
struct br_mrp_in_role {
|
||||
__u32 ring_id;
|
||||
__u32 in_role;
|
||||
__u32 i_ifindex;
|
||||
__u16 in_id;
|
||||
};
|
||||
|
||||
struct br_mrp_start_in_test {
|
||||
__u32 interval;
|
||||
__u32 max_miss;
|
||||
__u32 period;
|
||||
__u16 in_id;
|
||||
};
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_MEP_CREATE,
|
||||
IFLA_BRIDGE_CFM_MEP_DELETE,
|
||||
IFLA_BRIDGE_CFM_MEP_CONFIG,
|
||||
IFLA_BRIDGE_CFM_CC_CONFIG,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE,
|
||||
IFLA_BRIDGE_CFM_CC_RDI,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX,
|
||||
IFLA_BRIDGE_CFM_MEP_CREATE_INFO,
|
||||
IFLA_BRIDGE_CFM_MEP_CONFIG_INFO,
|
||||
IFLA_BRIDGE_CFM_CC_CONFIG_INFO,
|
||||
IFLA_BRIDGE_CFM_CC_RDI_INFO,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_INFO,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_MEP_INFO,
|
||||
IFLA_BRIDGE_CFM_MEP_STATUS_INFO,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO,
|
||||
__IFLA_BRIDGE_CFM_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_MAX (__IFLA_BRIDGE_CFM_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_MEP_CREATE_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_MEP_CREATE_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_MEP_CREATE_DOMAIN,
|
||||
IFLA_BRIDGE_CFM_MEP_CREATE_DIRECTION,
|
||||
IFLA_BRIDGE_CFM_MEP_CREATE_IFINDEX,
|
||||
__IFLA_BRIDGE_CFM_MEP_CREATE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_MEP_CREATE_MAX (__IFLA_BRIDGE_CFM_MEP_CREATE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_MEP_DELETE_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_MEP_DELETE_INSTANCE,
|
||||
__IFLA_BRIDGE_CFM_MEP_DELETE_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_MEP_DELETE_MAX (__IFLA_BRIDGE_CFM_MEP_DELETE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_MEP_CONFIG_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_MEP_CONFIG_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_MEP_CONFIG_UNICAST_MAC,
|
||||
IFLA_BRIDGE_CFM_MEP_CONFIG_MDLEVEL,
|
||||
IFLA_BRIDGE_CFM_MEP_CONFIG_MEPID,
|
||||
__IFLA_BRIDGE_CFM_MEP_CONFIG_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_MEP_CONFIG_MAX (__IFLA_BRIDGE_CFM_MEP_CONFIG_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_CC_CONFIG_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE,
|
||||
IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL,
|
||||
IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID,
|
||||
__IFLA_BRIDGE_CFM_CC_CONFIG_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_CC_CONFIG_MAX (__IFLA_BRIDGE_CFM_CC_CONFIG_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_CC_PEER_MEP_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_MEP_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_MEPID,
|
||||
__IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX (__IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_CC_RDI_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_CC_RDI_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_CC_RDI_RDI,
|
||||
__IFLA_BRIDGE_CFM_CC_RDI_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_CC_RDI_MAX (__IFLA_BRIDGE_CFM_CC_RDI_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_DMAC,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_SEQ_NO_UPDATE,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_PERIOD,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV_VALUE,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV,
|
||||
IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV_VALUE,
|
||||
__IFLA_BRIDGE_CFM_CC_CCM_TX_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_CC_CCM_TX_MAX (__IFLA_BRIDGE_CFM_CC_CCM_TX_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_MEP_STATUS_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN,
|
||||
IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN,
|
||||
IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN,
|
||||
__IFLA_BRIDGE_CFM_MEP_STATUS_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_MEP_STATUS_MAX (__IFLA_BRIDGE_CFM_MEP_STATUS_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_UNSPEC,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_RDI,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_PORT_TLV_VALUE,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_IF_TLV_VALUE,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEEN,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_TLV_SEEN,
|
||||
IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEQ_UNEXP_SEEN,
|
||||
__IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX (__IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX - 1)
|
||||
|
||||
struct bridge_stp_xstats {
|
||||
__u64 transition_blk;
|
||||
__u64 transition_fwd;
|
||||
|
|
@ -479,22 +183,16 @@ enum {
|
|||
|
||||
/* flags used in BRIDGE_VLANDB_DUMP_FLAGS attribute to affect dumps */
|
||||
#define BRIDGE_VLANDB_DUMPF_STATS (1 << 0) /* Include stats in the dump */
|
||||
#define BRIDGE_VLANDB_DUMPF_GLOBAL (1 << 1) /* Dump global vlan options only */
|
||||
|
||||
/* Bridge vlan RTM attributes
|
||||
* [BRIDGE_VLANDB_ENTRY] = {
|
||||
* [BRIDGE_VLANDB_ENTRY_INFO]
|
||||
* ...
|
||||
* }
|
||||
* [BRIDGE_VLANDB_GLOBAL_OPTIONS] = {
|
||||
* [BRIDGE_VLANDB_GOPTS_ID]
|
||||
* ...
|
||||
* }
|
||||
*/
|
||||
enum {
|
||||
BRIDGE_VLANDB_UNSPEC,
|
||||
BRIDGE_VLANDB_ENTRY,
|
||||
BRIDGE_VLANDB_GLOBAL_OPTIONS,
|
||||
__BRIDGE_VLANDB_MAX,
|
||||
};
|
||||
#define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1)
|
||||
|
|
@ -506,7 +204,6 @@ enum {
|
|||
BRIDGE_VLANDB_ENTRY_STATE,
|
||||
BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,
|
||||
BRIDGE_VLANDB_ENTRY_STATS,
|
||||
BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
|
||||
__BRIDGE_VLANDB_ENTRY_MAX,
|
||||
};
|
||||
#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
|
||||
|
|
@ -545,29 +242,6 @@ enum {
|
|||
};
|
||||
#define BRIDGE_VLANDB_STATS_MAX (__BRIDGE_VLANDB_STATS_MAX - 1)
|
||||
|
||||
enum {
|
||||
BRIDGE_VLANDB_GOPTS_UNSPEC,
|
||||
BRIDGE_VLANDB_GOPTS_ID,
|
||||
BRIDGE_VLANDB_GOPTS_RANGE,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_SNOOPING,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_IGMP_VERSION,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_MLD_VERSION,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_CNT,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_CNT,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_LAST_MEMBER_INTVL,
|
||||
BRIDGE_VLANDB_GOPTS_PAD,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_MEMBERSHIP_INTVL,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERY_INTVL,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS,
|
||||
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE,
|
||||
__BRIDGE_VLANDB_GOPTS_MAX
|
||||
};
|
||||
#define BRIDGE_VLANDB_GOPTS_MAX (__BRIDGE_VLANDB_GOPTS_MAX - 1)
|
||||
|
||||
/* Bridge multicast database attributes
|
||||
* [MDBA_MDB] = {
|
||||
* [MDBA_MDB_ENTRY] = {
|
||||
|
|
@ -610,33 +284,10 @@ enum {
|
|||
enum {
|
||||
MDBA_MDB_EATTR_UNSPEC,
|
||||
MDBA_MDB_EATTR_TIMER,
|
||||
MDBA_MDB_EATTR_SRC_LIST,
|
||||
MDBA_MDB_EATTR_GROUP_MODE,
|
||||
MDBA_MDB_EATTR_SOURCE,
|
||||
MDBA_MDB_EATTR_RTPROT,
|
||||
__MDBA_MDB_EATTR_MAX
|
||||
};
|
||||
#define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1)
|
||||
|
||||
/* per mdb entry source */
|
||||
enum {
|
||||
MDBA_MDB_SRCLIST_UNSPEC,
|
||||
MDBA_MDB_SRCLIST_ENTRY,
|
||||
__MDBA_MDB_SRCLIST_MAX
|
||||
};
|
||||
#define MDBA_MDB_SRCLIST_MAX (__MDBA_MDB_SRCLIST_MAX - 1)
|
||||
|
||||
/* per mdb entry per source attributes
|
||||
* these are embedded in MDBA_MDB_SRCLIST_ENTRY
|
||||
*/
|
||||
enum {
|
||||
MDBA_MDB_SRCATTR_UNSPEC,
|
||||
MDBA_MDB_SRCATTR_ADDRESS,
|
||||
MDBA_MDB_SRCATTR_TIMER,
|
||||
__MDBA_MDB_SRCATTR_MAX
|
||||
};
|
||||
#define MDBA_MDB_SRCATTR_MAX (__MDBA_MDB_SRCATTR_MAX - 1)
|
||||
|
||||
/* multicast router types */
|
||||
enum {
|
||||
MDB_RTR_TYPE_DISABLED,
|
||||
|
|
@ -657,9 +308,6 @@ enum {
|
|||
MDBA_ROUTER_PATTR_UNSPEC,
|
||||
MDBA_ROUTER_PATTR_TIMER,
|
||||
MDBA_ROUTER_PATTR_TYPE,
|
||||
MDBA_ROUTER_PATTR_INET_TIMER,
|
||||
MDBA_ROUTER_PATTR_INET6_TIMER,
|
||||
MDBA_ROUTER_PATTR_VID,
|
||||
__MDBA_ROUTER_PATTR_MAX
|
||||
};
|
||||
#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
|
||||
|
|
@ -676,15 +324,12 @@ struct br_mdb_entry {
|
|||
__u8 state;
|
||||
#define MDB_FLAGS_OFFLOAD (1 << 0)
|
||||
#define MDB_FLAGS_FAST_LEAVE (1 << 1)
|
||||
#define MDB_FLAGS_STAR_EXCL (1 << 2)
|
||||
#define MDB_FLAGS_BLOCKED (1 << 3)
|
||||
__u8 flags;
|
||||
__u16 vid;
|
||||
struct {
|
||||
union {
|
||||
__be32 ip4;
|
||||
struct in6_addr ip6;
|
||||
unsigned char mac_addr[ETH_ALEN];
|
||||
} u;
|
||||
__be16 proto;
|
||||
} addr;
|
||||
|
|
@ -693,23 +338,10 @@ struct br_mdb_entry {
|
|||
enum {
|
||||
MDBA_SET_ENTRY_UNSPEC,
|
||||
MDBA_SET_ENTRY,
|
||||
MDBA_SET_ENTRY_ATTRS,
|
||||
__MDBA_SET_ENTRY_MAX,
|
||||
};
|
||||
#define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1)
|
||||
|
||||
/* [MDBA_SET_ENTRY_ATTRS] = {
|
||||
* [MDBE_ATTR_xxx]
|
||||
* ...
|
||||
* }
|
||||
*/
|
||||
enum {
|
||||
MDBE_ATTR_UNSPEC,
|
||||
MDBE_ATTR_SOURCE,
|
||||
__MDBE_ATTR_MAX,
|
||||
};
|
||||
#define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1)
|
||||
|
||||
/* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
|
||||
enum {
|
||||
BRIDGE_XSTATS_UNSPEC,
|
||||
|
|
@ -751,14 +383,12 @@ struct br_mcast_stats {
|
|||
|
||||
/* bridge boolean options
|
||||
* BR_BOOLOPT_NO_LL_LEARN - disable learning from link-local packets
|
||||
* BR_BOOLOPT_MCAST_VLAN_SNOOPING - control vlan multicast snooping
|
||||
*
|
||||
* IMPORTANT: if adding a new option do not forget to handle
|
||||
* it in br_boolopt_toggle/get and bridge sysfs
|
||||
*/
|
||||
enum br_boolopt_id {
|
||||
BR_BOOLOPT_NO_LL_LEARN,
|
||||
BR_BOOLOPT_MCAST_VLAN_SNOOPING,
|
||||
BR_BOOLOPT_MAX
|
||||
};
|
||||
|
||||
|
|
@ -771,17 +401,4 @@ struct br_boolopt_multi {
|
|||
__u32 optval;
|
||||
__u32 optmask;
|
||||
};
|
||||
|
||||
enum {
|
||||
BRIDGE_QUERIER_UNSPEC,
|
||||
BRIDGE_QUERIER_IP_ADDRESS,
|
||||
BRIDGE_QUERIER_IP_PORT,
|
||||
BRIDGE_QUERIER_IP_OTHER_TIMER,
|
||||
BRIDGE_QUERIER_PAD,
|
||||
BRIDGE_QUERIER_IPV6_ADDRESS,
|
||||
BRIDGE_QUERIER_IPV6_PORT,
|
||||
BRIDGE_QUERIER_IPV6_OTHER_TIMER,
|
||||
__BRIDGE_QUERIER_MAX
|
||||
};
|
||||
#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1)
|
||||
#endif /* _LINUX_IF_BRIDGE_H */
|
||||
|
|
|
|||
|
|
@ -86,21 +86,18 @@
|
|||
* over Ethernet
|
||||
*/
|
||||
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
|
||||
#define ETH_P_REALTEK 0x8899 /* Multiple proprietary protocols */
|
||||
#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
|
||||
#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */
|
||||
#define ETH_P_802_EX1 0x88B5 /* 802.1 Local Experimental 1. */
|
||||
#define ETH_P_PREAUTH 0x88C7 /* 802.11 Preauthentication */
|
||||
#define ETH_P_TIPC 0x88CA /* TIPC */
|
||||
#define ETH_P_LLDP 0x88CC /* Link Layer Discovery Protocol */
|
||||
#define ETH_P_MRP 0x88E3 /* Media Redundancy Protocol */
|
||||
#define ETH_P_MACSEC 0x88E5 /* 802.1ae MACsec */
|
||||
#define ETH_P_8021AH 0x88E7 /* 802.1ah Backbone Service Tag */
|
||||
#define ETH_P_MVRP 0x88F5 /* 802.1Q MVRP */
|
||||
#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
|
||||
#define ETH_P_NCSI 0x88F8 /* NCSI protocol */
|
||||
#define ETH_P_PRP 0x88FB /* IEC 62439-3 PRP/HSRv0 */
|
||||
#define ETH_P_CFM 0x8902 /* Connectivity Fault Management */
|
||||
#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
|
||||
#define ETH_P_IBOE 0x8915 /* Infiniband over Ethernet */
|
||||
#define ETH_P_TDLS 0x890D /* TDLS */
|
||||
|
|
@ -117,7 +114,7 @@
|
|||
#define ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */
|
||||
#define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */
|
||||
|
||||
#define ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is more than this value
|
||||
#define ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is less than this value
|
||||
* then the frame is Ethernet II. Else it is 802.3 */
|
||||
|
||||
/*
|
||||
|
|
@ -152,9 +149,6 @@
|
|||
#define ETH_P_MAP 0x00F9 /* Qualcomm multiplexing and
|
||||
* aggregation protocol
|
||||
*/
|
||||
#define ETH_P_MCTP 0x00FA /* Management component transport
|
||||
* protocol packets
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is an Ethernet frame header.
|
||||
|
|
|
|||
|
|
@ -7,23 +7,24 @@
|
|||
|
||||
/* This struct should be in sync with struct rtnl_link_stats64 */
|
||||
struct rtnl_link_stats {
|
||||
__u32 rx_packets;
|
||||
__u32 tx_packets;
|
||||
__u32 rx_bytes;
|
||||
__u32 tx_bytes;
|
||||
__u32 rx_errors;
|
||||
__u32 tx_errors;
|
||||
__u32 rx_dropped;
|
||||
__u32 tx_dropped;
|
||||
__u32 multicast;
|
||||
__u32 rx_packets; /* total packets received */
|
||||
__u32 tx_packets; /* total packets transmitted */
|
||||
__u32 rx_bytes; /* total bytes received */
|
||||
__u32 tx_bytes; /* total bytes transmitted */
|
||||
__u32 rx_errors; /* bad packets received */
|
||||
__u32 tx_errors; /* packet transmit problems */
|
||||
__u32 rx_dropped; /* no space in linux buffers */
|
||||
__u32 tx_dropped; /* no space available in linux */
|
||||
__u32 multicast; /* multicast packets received */
|
||||
__u32 collisions;
|
||||
|
||||
/* detailed rx_errors: */
|
||||
__u32 rx_length_errors;
|
||||
__u32 rx_over_errors;
|
||||
__u32 rx_crc_errors;
|
||||
__u32 rx_frame_errors;
|
||||
__u32 rx_fifo_errors;
|
||||
__u32 rx_missed_errors;
|
||||
__u32 rx_over_errors; /* receiver ring buff overflow */
|
||||
__u32 rx_crc_errors; /* recved pkt with crc error */
|
||||
__u32 rx_frame_errors; /* recv'd frame alignment error */
|
||||
__u32 rx_fifo_errors; /* recv'r fifo overrun */
|
||||
__u32 rx_missed_errors; /* receiver missed packet */
|
||||
|
||||
/* detailed tx_errors */
|
||||
__u32 tx_aborted_errors;
|
||||
|
|
@ -36,201 +37,29 @@ struct rtnl_link_stats {
|
|||
__u32 rx_compressed;
|
||||
__u32 tx_compressed;
|
||||
|
||||
__u32 rx_nohandler;
|
||||
__u32 rx_nohandler; /* dropped, no handler found */
|
||||
};
|
||||
|
||||
/**
|
||||
* struct rtnl_link_stats64 - The main device statistics structure.
|
||||
*
|
||||
* @rx_packets: Number of good packets received by the interface.
|
||||
* For hardware interfaces counts all good packets received from the device
|
||||
* by the host, including packets which host had to drop at various stages
|
||||
* of processing (even in the driver).
|
||||
*
|
||||
* @tx_packets: Number of packets successfully transmitted.
|
||||
* For hardware interfaces counts packets which host was able to successfully
|
||||
* hand over to the device, which does not necessarily mean that packets
|
||||
* had been successfully transmitted out of the device, only that device
|
||||
* acknowledged it copied them out of host memory.
|
||||
*
|
||||
* @rx_bytes: Number of good received bytes, corresponding to @rx_packets.
|
||||
*
|
||||
* For IEEE 802.3 devices should count the length of Ethernet Frames
|
||||
* excluding the FCS.
|
||||
*
|
||||
* @tx_bytes: Number of good transmitted bytes, corresponding to @tx_packets.
|
||||
*
|
||||
* For IEEE 802.3 devices should count the length of Ethernet Frames
|
||||
* excluding the FCS.
|
||||
*
|
||||
* @rx_errors: Total number of bad packets received on this network device.
|
||||
* This counter must include events counted by @rx_length_errors,
|
||||
* @rx_crc_errors, @rx_frame_errors and other errors not otherwise
|
||||
* counted.
|
||||
*
|
||||
* @tx_errors: Total number of transmit problems.
|
||||
* This counter must include events counter by @tx_aborted_errors,
|
||||
* @tx_carrier_errors, @tx_fifo_errors, @tx_heartbeat_errors,
|
||||
* @tx_window_errors and other errors not otherwise counted.
|
||||
*
|
||||
* @rx_dropped: Number of packets received but not processed,
|
||||
* e.g. due to lack of resources or unsupported protocol.
|
||||
* For hardware interfaces this counter may include packets discarded
|
||||
* due to L2 address filtering but should not include packets dropped
|
||||
* by the device due to buffer exhaustion which are counted separately in
|
||||
* @rx_missed_errors (since procfs folds those two counters together).
|
||||
*
|
||||
* @tx_dropped: Number of packets dropped on their way to transmission,
|
||||
* e.g. due to lack of resources.
|
||||
*
|
||||
* @multicast: Multicast packets received.
|
||||
* For hardware interfaces this statistic is commonly calculated
|
||||
* at the device level (unlike @rx_packets) and therefore may include
|
||||
* packets which did not reach the host.
|
||||
*
|
||||
* For IEEE 802.3 devices this counter may be equivalent to:
|
||||
*
|
||||
* - 30.3.1.1.21 aMulticastFramesReceivedOK
|
||||
*
|
||||
* @collisions: Number of collisions during packet transmissions.
|
||||
*
|
||||
* @rx_length_errors: Number of packets dropped due to invalid length.
|
||||
* Part of aggregate "frame" errors in `/proc/net/dev`.
|
||||
*
|
||||
* For IEEE 802.3 devices this counter should be equivalent to a sum
|
||||
* of the following attributes:
|
||||
*
|
||||
* - 30.3.1.1.23 aInRangeLengthErrors
|
||||
* - 30.3.1.1.24 aOutOfRangeLengthField
|
||||
* - 30.3.1.1.25 aFrameTooLongErrors
|
||||
*
|
||||
* @rx_over_errors: Receiver FIFO overflow event counter.
|
||||
*
|
||||
* Historically the count of overflow events. Such events may be
|
||||
* reported in the receive descriptors or via interrupts, and may
|
||||
* not correspond one-to-one with dropped packets.
|
||||
*
|
||||
* The recommended interpretation for high speed interfaces is -
|
||||
* number of packets dropped because they did not fit into buffers
|
||||
* provided by the host, e.g. packets larger than MTU or next buffer
|
||||
* in the ring was not available for a scatter transfer.
|
||||
*
|
||||
* Part of aggregate "frame" errors in `/proc/net/dev`.
|
||||
*
|
||||
* This statistics was historically used interchangeably with
|
||||
* @rx_fifo_errors.
|
||||
*
|
||||
* This statistic corresponds to hardware events and is not commonly used
|
||||
* on software devices.
|
||||
*
|
||||
* @rx_crc_errors: Number of packets received with a CRC error.
|
||||
* Part of aggregate "frame" errors in `/proc/net/dev`.
|
||||
*
|
||||
* For IEEE 802.3 devices this counter must be equivalent to:
|
||||
*
|
||||
* - 30.3.1.1.6 aFrameCheckSequenceErrors
|
||||
*
|
||||
* @rx_frame_errors: Receiver frame alignment errors.
|
||||
* Part of aggregate "frame" errors in `/proc/net/dev`.
|
||||
*
|
||||
* For IEEE 802.3 devices this counter should be equivalent to:
|
||||
*
|
||||
* - 30.3.1.1.7 aAlignmentErrors
|
||||
*
|
||||
* @rx_fifo_errors: Receiver FIFO error counter.
|
||||
*
|
||||
* Historically the count of overflow events. Those events may be
|
||||
* reported in the receive descriptors or via interrupts, and may
|
||||
* not correspond one-to-one with dropped packets.
|
||||
*
|
||||
* This statistics was used interchangeably with @rx_over_errors.
|
||||
* Not recommended for use in drivers for high speed interfaces.
|
||||
*
|
||||
* This statistic is used on software devices, e.g. to count software
|
||||
* packet queue overflow (can) or sequencing errors (GRE).
|
||||
*
|
||||
* @rx_missed_errors: Count of packets missed by the host.
|
||||
* Folded into the "drop" counter in `/proc/net/dev`.
|
||||
*
|
||||
* Counts number of packets dropped by the device due to lack
|
||||
* of buffer space. This usually indicates that the host interface
|
||||
* is slower than the network interface, or host is not keeping up
|
||||
* with the receive packet rate.
|
||||
*
|
||||
* This statistic corresponds to hardware events and is not used
|
||||
* on software devices.
|
||||
*
|
||||
* @tx_aborted_errors:
|
||||
* Part of aggregate "carrier" errors in `/proc/net/dev`.
|
||||
* For IEEE 802.3 devices capable of half-duplex operation this counter
|
||||
* must be equivalent to:
|
||||
*
|
||||
* - 30.3.1.1.11 aFramesAbortedDueToXSColls
|
||||
*
|
||||
* High speed interfaces may use this counter as a general device
|
||||
* discard counter.
|
||||
*
|
||||
* @tx_carrier_errors: Number of frame transmission errors due to loss
|
||||
* of carrier during transmission.
|
||||
* Part of aggregate "carrier" errors in `/proc/net/dev`.
|
||||
*
|
||||
* For IEEE 802.3 devices this counter must be equivalent to:
|
||||
*
|
||||
* - 30.3.1.1.13 aCarrierSenseErrors
|
||||
*
|
||||
* @tx_fifo_errors: Number of frame transmission errors due to device
|
||||
* FIFO underrun / underflow. This condition occurs when the device
|
||||
* begins transmission of a frame but is unable to deliver the
|
||||
* entire frame to the transmitter in time for transmission.
|
||||
* Part of aggregate "carrier" errors in `/proc/net/dev`.
|
||||
*
|
||||
* @tx_heartbeat_errors: Number of Heartbeat / SQE Test errors for
|
||||
* old half-duplex Ethernet.
|
||||
* Part of aggregate "carrier" errors in `/proc/net/dev`.
|
||||
*
|
||||
* For IEEE 802.3 devices possibly equivalent to:
|
||||
*
|
||||
* - 30.3.2.1.4 aSQETestErrors
|
||||
*
|
||||
* @tx_window_errors: Number of frame transmission errors due
|
||||
* to late collisions (for Ethernet - after the first 64B of transmission).
|
||||
* Part of aggregate "carrier" errors in `/proc/net/dev`.
|
||||
*
|
||||
* For IEEE 802.3 devices this counter must be equivalent to:
|
||||
*
|
||||
* - 30.3.1.1.10 aLateCollisions
|
||||
*
|
||||
* @rx_compressed: Number of correctly received compressed packets.
|
||||
* This counters is only meaningful for interfaces which support
|
||||
* packet compression (e.g. CSLIP, PPP).
|
||||
*
|
||||
* @tx_compressed: Number of transmitted compressed packets.
|
||||
* This counters is only meaningful for interfaces which support
|
||||
* packet compression (e.g. CSLIP, PPP).
|
||||
*
|
||||
* @rx_nohandler: Number of packets received on the interface
|
||||
* but dropped by the networking stack because the device is
|
||||
* not designated to receive packets (e.g. backup link in a bond).
|
||||
*/
|
||||
/* The main device statistics structure */
|
||||
struct rtnl_link_stats64 {
|
||||
__u64 rx_packets;
|
||||
__u64 tx_packets;
|
||||
__u64 rx_bytes;
|
||||
__u64 tx_bytes;
|
||||
__u64 rx_errors;
|
||||
__u64 tx_errors;
|
||||
__u64 rx_dropped;
|
||||
__u64 tx_dropped;
|
||||
__u64 multicast;
|
||||
__u64 rx_packets; /* total packets received */
|
||||
__u64 tx_packets; /* total packets transmitted */
|
||||
__u64 rx_bytes; /* total bytes received */
|
||||
__u64 tx_bytes; /* total bytes transmitted */
|
||||
__u64 rx_errors; /* bad packets received */
|
||||
__u64 tx_errors; /* packet transmit problems */
|
||||
__u64 rx_dropped; /* no space in linux buffers */
|
||||
__u64 tx_dropped; /* no space available in linux */
|
||||
__u64 multicast; /* multicast packets received */
|
||||
__u64 collisions;
|
||||
|
||||
/* detailed rx_errors: */
|
||||
__u64 rx_length_errors;
|
||||
__u64 rx_over_errors;
|
||||
__u64 rx_crc_errors;
|
||||
__u64 rx_frame_errors;
|
||||
__u64 rx_fifo_errors;
|
||||
__u64 rx_missed_errors;
|
||||
__u64 rx_over_errors; /* receiver ring buff overflow */
|
||||
__u64 rx_crc_errors; /* recved pkt with crc error */
|
||||
__u64 rx_frame_errors; /* recv'd frame alignment error */
|
||||
__u64 rx_fifo_errors; /* recv'r fifo overrun */
|
||||
__u64 rx_missed_errors; /* receiver missed packet */
|
||||
|
||||
/* detailed tx_errors */
|
||||
__u64 tx_aborted_errors;
|
||||
|
|
@ -242,7 +71,8 @@ struct rtnl_link_stats64 {
|
|||
/* for cslip etc */
|
||||
__u64 rx_compressed;
|
||||
__u64 tx_compressed;
|
||||
__u64 rx_nohandler;
|
||||
|
||||
__u64 rx_nohandler; /* dropped, no handler found */
|
||||
};
|
||||
|
||||
/* The struct should be in sync with struct ifmap */
|
||||
|
|
@ -340,29 +170,12 @@ enum {
|
|||
IFLA_PROP_LIST,
|
||||
IFLA_ALT_IFNAME, /* Alternative ifname */
|
||||
IFLA_PERM_ADDRESS,
|
||||
IFLA_PROTO_DOWN_REASON,
|
||||
|
||||
/* device (sysfs) name as parent, used instead
|
||||
* of IFLA_LINK where there's no parent netdev
|
||||
*/
|
||||
IFLA_PARENT_DEV_NAME,
|
||||
IFLA_PARENT_DEV_BUS_NAME,
|
||||
|
||||
__IFLA_MAX
|
||||
};
|
||||
|
||||
|
||||
#define IFLA_MAX (__IFLA_MAX - 1)
|
||||
|
||||
enum {
|
||||
IFLA_PROTO_DOWN_REASON_UNSPEC,
|
||||
IFLA_PROTO_DOWN_REASON_MASK, /* u32, mask for reason bits */
|
||||
IFLA_PROTO_DOWN_REASON_VALUE, /* u32, reason bit value */
|
||||
|
||||
__IFLA_PROTO_DOWN_REASON_CNT,
|
||||
IFLA_PROTO_DOWN_REASON_MAX = __IFLA_PROTO_DOWN_REASON_CNT - 1
|
||||
};
|
||||
|
||||
/* backwards compatibility for userspace */
|
||||
#define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
|
||||
#define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
|
||||
|
|
@ -415,7 +228,6 @@ enum {
|
|||
IFLA_INET6_ICMP6STATS, /* statistics (icmpv6) */
|
||||
IFLA_INET6_TOKEN, /* device token */
|
||||
IFLA_INET6_ADDR_GEN_MODE, /* implicit address generator mode */
|
||||
IFLA_INET6_RA_MTU, /* mtu carried in the RA message */
|
||||
__IFLA_INET6_MAX
|
||||
};
|
||||
|
||||
|
|
@ -478,7 +290,6 @@ enum {
|
|||
IFLA_BR_MCAST_MLD_VERSION,
|
||||
IFLA_BR_VLAN_STATS_PER_PORT,
|
||||
IFLA_BR_MULTI_BOOLOPT,
|
||||
IFLA_BR_MCAST_QUERIER_STATE,
|
||||
__IFLA_BR_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -530,10 +341,6 @@ enum {
|
|||
IFLA_BRPORT_NEIGH_SUPPRESS,
|
||||
IFLA_BRPORT_ISOLATED,
|
||||
IFLA_BRPORT_BACKUP_PORT,
|
||||
IFLA_BRPORT_MRP_RING_OPEN,
|
||||
IFLA_BRPORT_MRP_IN_OPEN,
|
||||
IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
|
||||
IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
|
||||
__IFLA_BRPORT_MAX
|
||||
};
|
||||
#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
|
||||
|
|
@ -598,8 +405,6 @@ enum {
|
|||
IFLA_MACVLAN_MACADDR,
|
||||
IFLA_MACVLAN_MACADDR_DATA,
|
||||
IFLA_MACVLAN_MACADDR_COUNT,
|
||||
IFLA_MACVLAN_BC_QUEUE_LEN,
|
||||
IFLA_MACVLAN_BC_QUEUE_LEN_USED,
|
||||
__IFLA_MACVLAN_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -621,7 +426,6 @@ enum macvlan_macaddr_mode {
|
|||
};
|
||||
|
||||
#define MACVLAN_FLAG_NOPROMISC 1
|
||||
#define MACVLAN_FLAG_NODST 2 /* skip dst macvlan if matching src macvlan */
|
||||
|
||||
/* VRF section */
|
||||
enum {
|
||||
|
|
@ -855,7 +659,6 @@ enum {
|
|||
IFLA_BOND_AD_ACTOR_SYSTEM,
|
||||
IFLA_BOND_TLB_DYNAMIC_LB,
|
||||
IFLA_BOND_PEER_NOTIF_DELAY,
|
||||
IFLA_BOND_AD_LACP_ACTIVE,
|
||||
__IFLA_BOND_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -1100,14 +903,7 @@ enum {
|
|||
#define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1)
|
||||
|
||||
|
||||
/* HSR/PRP section, both uses same interface */
|
||||
|
||||
/* Different redundancy protocols for hsr device */
|
||||
enum {
|
||||
HSR_PROTOCOL_HSR,
|
||||
HSR_PROTOCOL_PRP,
|
||||
HSR_PROTOCOL_MAX,
|
||||
};
|
||||
/* HSR section */
|
||||
|
||||
enum {
|
||||
IFLA_HSR_UNSPEC,
|
||||
|
|
@ -1117,9 +913,6 @@ enum {
|
|||
IFLA_HSR_SUPERVISION_ADDR, /* Supervision frame multicast addr */
|
||||
IFLA_HSR_SEQ_NR,
|
||||
IFLA_HSR_VERSION, /* HSR version */
|
||||
IFLA_HSR_PROTOCOL, /* Indicate different protocol than
|
||||
* HSR. For example PRP.
|
||||
*/
|
||||
__IFLA_HSR_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -1244,8 +1037,6 @@ enum {
|
|||
#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1)
|
||||
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2)
|
||||
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3)
|
||||
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 4)
|
||||
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 5)
|
||||
|
||||
enum {
|
||||
IFLA_RMNET_UNSPEC,
|
||||
|
|
@ -1261,14 +1052,4 @@ struct ifla_rmnet_flags {
|
|||
__u32 mask;
|
||||
};
|
||||
|
||||
/* MCTP section */
|
||||
|
||||
enum {
|
||||
IFLA_MCTP_UNSPEC,
|
||||
IFLA_MCTP_NET,
|
||||
__IFLA_MCTP_MAX,
|
||||
};
|
||||
|
||||
#define IFLA_MCTP_MAX (__IFLA_MCTP_MAX - 1)
|
||||
|
||||
#endif /* _LINUX_IF_LINK_H */
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#ifndef __LINUX_IF_PACKET_H
|
||||
#define __LINUX_IF_PACKET_H
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
struct sockaddr_pkt {
|
||||
|
|
@ -297,17 +296,6 @@ struct packet_mreq {
|
|||
unsigned char mr_address[8];
|
||||
};
|
||||
|
||||
struct fanout_args {
|
||||
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
||||
__u16 id;
|
||||
__u16 type_flags;
|
||||
#else
|
||||
__u16 type_flags;
|
||||
__u16 id;
|
||||
#endif
|
||||
__u32 max_num_members;
|
||||
};
|
||||
|
||||
#define PACKET_MR_MULTICAST 0
|
||||
#define PACKET_MR_PROMISC 1
|
||||
#define PACKET_MR_ALLMULTI 2
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ struct in_addr {
|
|||
#define IP_CHECKSUM 23
|
||||
#define IP_BIND_ADDRESS_NO_PORT 24
|
||||
#define IP_RECVFRAGSIZE 25
|
||||
#define IP_RECVERR_RFC4884 26
|
||||
|
||||
/* IP_MTU_DISCOVER values */
|
||||
#define IP_PMTUDISC_DONT 0 /* Never send DF frames */
|
||||
|
|
@ -135,7 +134,7 @@ struct in_addr {
|
|||
* this socket to prevent accepting spoofed ones.
|
||||
*/
|
||||
#define IP_PMTUDISC_INTERFACE 4
|
||||
/* weaker version of IP_PMTUDISC_INTERFACE, which allows packets to get
|
||||
/* weaker version of IP_PMTUDISC_INTERFACE, which allos packets to get
|
||||
* fragmented if they exeed the interface mtu
|
||||
*/
|
||||
#define IP_PMTUDISC_OMIT 5
|
||||
|
|
@ -188,22 +187,11 @@ struct ip_mreq_source {
|
|||
};
|
||||
|
||||
struct ip_msfilter {
|
||||
union {
|
||||
struct {
|
||||
__be32 imsf_multiaddr_aux;
|
||||
__be32 imsf_interface_aux;
|
||||
__u32 imsf_fmode_aux;
|
||||
__u32 imsf_numsrc_aux;
|
||||
__be32 imsf_slist[1];
|
||||
};
|
||||
struct {
|
||||
__be32 imsf_multiaddr;
|
||||
__be32 imsf_interface;
|
||||
__u32 imsf_fmode;
|
||||
__u32 imsf_numsrc;
|
||||
__be32 imsf_slist_flex[];
|
||||
};
|
||||
};
|
||||
__be32 imsf_multiaddr;
|
||||
__be32 imsf_interface;
|
||||
__u32 imsf_fmode;
|
||||
__u32 imsf_numsrc;
|
||||
__be32 imsf_slist[1];
|
||||
};
|
||||
|
||||
#define IP_MSFILTER_SIZE(numsrc) \
|
||||
|
|
@ -222,22 +210,11 @@ struct group_source_req {
|
|||
};
|
||||
|
||||
struct group_filter {
|
||||
union {
|
||||
struct {
|
||||
__u32 gf_interface_aux; /* interface index */
|
||||
struct __kernel_sockaddr_storage gf_group_aux; /* multicast address */
|
||||
__u32 gf_fmode_aux; /* filter mode */
|
||||
__u32 gf_numsrc_aux; /* number of sources */
|
||||
struct __kernel_sockaddr_storage gf_slist[1]; /* interface index */
|
||||
};
|
||||
struct {
|
||||
__u32 gf_interface; /* interface index */
|
||||
struct __kernel_sockaddr_storage gf_group; /* multicast address */
|
||||
__u32 gf_fmode; /* filter mode */
|
||||
__u32 gf_numsrc; /* number of sources */
|
||||
struct __kernel_sockaddr_storage gf_slist_flex[]; /* interface index */
|
||||
};
|
||||
};
|
||||
__u32 gf_interface; /* interface index */
|
||||
struct __kernel_sockaddr_storage gf_group; /* multicast address */
|
||||
__u32 gf_fmode; /* filter mode */
|
||||
__u32 gf_numsrc; /* number of sources */
|
||||
struct __kernel_sockaddr_storage gf_slist[1]; /* interface index */
|
||||
};
|
||||
|
||||
#define GROUP_FILTER_SIZE(numsrc) \
|
||||
|
|
@ -311,9 +288,6 @@ struct sockaddr_in {
|
|||
/* Address indicating an error return. */
|
||||
#define INADDR_NONE ((unsigned long int) 0xffffffff)
|
||||
|
||||
/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */
|
||||
#define INADDR_DUMMY ((unsigned long int) 0xc0000008)
|
||||
|
||||
/* Network number for local host loopback. */
|
||||
#define IN_LOOPBACKNET 127
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,6 @@ struct in6_flowlabel_req {
|
|||
#define IPV6_TLV_PADN 1
|
||||
#define IPV6_TLV_ROUTERALERT 5
|
||||
#define IPV6_TLV_CALIPSO 7 /* RFC 5570 */
|
||||
#define IPV6_TLV_IOAM 49 /* TEMPORARY IANA allocation for IOAM */
|
||||
#define IPV6_TLV_JUMBO 194
|
||||
#define IPV6_TLV_HAO 201 /* home address option */
|
||||
|
||||
|
|
@ -180,7 +179,6 @@ struct in6_flowlabel_req {
|
|||
#define IPV6_LEAVE_ANYCAST 28
|
||||
#define IPV6_MULTICAST_ALL 29
|
||||
#define IPV6_ROUTER_ALERT_ISOLATE 30
|
||||
#define IPV6_RECVERR_RFC4884 31
|
||||
|
||||
/* IPV6_MTU_DISCOVER values */
|
||||
#define IPV6_PMTUDISC_DONT 0
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ enum {
|
|||
INET_DIAG_REQ_NONE,
|
||||
INET_DIAG_REQ_BYTECODE,
|
||||
INET_DIAG_REQ_SK_BPF_STORAGES,
|
||||
INET_DIAG_REQ_PROTOCOL,
|
||||
__INET_DIAG_REQ_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -97,7 +96,6 @@ enum {
|
|||
INET_DIAG_BC_MARK_COND,
|
||||
INET_DIAG_BC_S_EQ,
|
||||
INET_DIAG_BC_D_EQ,
|
||||
INET_DIAG_BC_CGROUP_COND, /* u64 cgroup v2 ID */
|
||||
};
|
||||
|
||||
struct inet_diag_hostcond {
|
||||
|
|
@ -159,8 +157,6 @@ enum {
|
|||
INET_DIAG_MD5SIG,
|
||||
INET_DIAG_ULP_INFO,
|
||||
INET_DIAG_SK_BPF_STORAGES,
|
||||
INET_DIAG_CGROUP_ID,
|
||||
INET_DIAG_SOCKOPT,
|
||||
__INET_DIAG_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -184,23 +180,6 @@ struct inet_diag_meminfo {
|
|||
__u32 idiag_tmem;
|
||||
};
|
||||
|
||||
/* INET_DIAG_SOCKOPT */
|
||||
|
||||
struct inet_diag_sockopt {
|
||||
__u8 recverr:1,
|
||||
is_icsk:1,
|
||||
freebind:1,
|
||||
hdrincl:1,
|
||||
mc_loop:1,
|
||||
transparent:1,
|
||||
mc_all:1,
|
||||
nodefrag:1;
|
||||
__u8 bind_address_no_port:1,
|
||||
recverr_rfc4884:1,
|
||||
defer_connect:1,
|
||||
unused:5;
|
||||
};
|
||||
|
||||
/* INET_DIAG_VEGASINFO */
|
||||
|
||||
struct tcpvegas_info {
|
||||
|
|
|
|||
|
|
@ -1,133 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
/*
|
||||
* IPv6 IOAM implementation
|
||||
*
|
||||
* Author:
|
||||
* Justin Iurman <justin.iurman@uliege.be>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_IOAM6_H
|
||||
#define _LINUX_IOAM6_H
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define IOAM6_U16_UNAVAILABLE U16_MAX
|
||||
#define IOAM6_U32_UNAVAILABLE U32_MAX
|
||||
#define IOAM6_U64_UNAVAILABLE U64_MAX
|
||||
|
||||
#define IOAM6_DEFAULT_ID (IOAM6_U32_UNAVAILABLE >> 8)
|
||||
#define IOAM6_DEFAULT_ID_WIDE (IOAM6_U64_UNAVAILABLE >> 8)
|
||||
#define IOAM6_DEFAULT_IF_ID IOAM6_U16_UNAVAILABLE
|
||||
#define IOAM6_DEFAULT_IF_ID_WIDE IOAM6_U32_UNAVAILABLE
|
||||
|
||||
/*
|
||||
* IPv6 IOAM Option Header
|
||||
*/
|
||||
struct ioam6_hdr {
|
||||
__u8 opt_type;
|
||||
__u8 opt_len;
|
||||
__u8 :8; /* reserved */
|
||||
#define IOAM6_TYPE_PREALLOC 0
|
||||
__u8 type;
|
||||
} __attribute__((packed));
|
||||
|
||||
/*
|
||||
* IOAM Trace Header
|
||||
*/
|
||||
struct ioam6_trace_hdr {
|
||||
__be16 namespace_id;
|
||||
|
||||
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
||||
|
||||
__u8 :1, /* unused */
|
||||
:1, /* unused */
|
||||
overflow:1,
|
||||
nodelen:5;
|
||||
|
||||
__u8 remlen:7,
|
||||
:1; /* unused */
|
||||
|
||||
union {
|
||||
__be32 type_be32;
|
||||
|
||||
struct {
|
||||
__u32 bit7:1,
|
||||
bit6:1,
|
||||
bit5:1,
|
||||
bit4:1,
|
||||
bit3:1,
|
||||
bit2:1,
|
||||
bit1:1,
|
||||
bit0:1,
|
||||
bit15:1, /* unused */
|
||||
bit14:1, /* unused */
|
||||
bit13:1, /* unused */
|
||||
bit12:1, /* unused */
|
||||
bit11:1,
|
||||
bit10:1,
|
||||
bit9:1,
|
||||
bit8:1,
|
||||
bit23:1, /* reserved */
|
||||
bit22:1,
|
||||
bit21:1, /* unused */
|
||||
bit20:1, /* unused */
|
||||
bit19:1, /* unused */
|
||||
bit18:1, /* unused */
|
||||
bit17:1, /* unused */
|
||||
bit16:1, /* unused */
|
||||
:8; /* reserved */
|
||||
} type;
|
||||
};
|
||||
|
||||
#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
|
||||
__u8 nodelen:5,
|
||||
overflow:1,
|
||||
:1, /* unused */
|
||||
:1; /* unused */
|
||||
|
||||
__u8 :1, /* unused */
|
||||
remlen:7;
|
||||
|
||||
union {
|
||||
__be32 type_be32;
|
||||
|
||||
struct {
|
||||
__u32 bit0:1,
|
||||
bit1:1,
|
||||
bit2:1,
|
||||
bit3:1,
|
||||
bit4:1,
|
||||
bit5:1,
|
||||
bit6:1,
|
||||
bit7:1,
|
||||
bit8:1,
|
||||
bit9:1,
|
||||
bit10:1,
|
||||
bit11:1,
|
||||
bit12:1, /* unused */
|
||||
bit13:1, /* unused */
|
||||
bit14:1, /* unused */
|
||||
bit15:1, /* unused */
|
||||
bit16:1, /* unused */
|
||||
bit17:1, /* unused */
|
||||
bit18:1, /* unused */
|
||||
bit19:1, /* unused */
|
||||
bit20:1, /* unused */
|
||||
bit21:1, /* unused */
|
||||
bit22:1,
|
||||
bit23:1, /* reserved */
|
||||
:8; /* reserved */
|
||||
} type;
|
||||
};
|
||||
|
||||
#else
|
||||
#error "Please fix <asm/byteorder.h>"
|
||||
#endif
|
||||
|
||||
#define IOAM6_TRACE_DATA_SIZE_MAX 244
|
||||
__u8 data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
#endif /* _LINUX_IOAM6_H */
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
/*
|
||||
* IPv6 IOAM Generic Netlink API
|
||||
*
|
||||
* Author:
|
||||
* Justin Iurman <justin.iurman@uliege.be>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_IOAM6_GENL_H
|
||||
#define _LINUX_IOAM6_GENL_H
|
||||
|
||||
#define IOAM6_GENL_NAME "IOAM6"
|
||||
#define IOAM6_GENL_VERSION 0x1
|
||||
|
||||
enum {
|
||||
IOAM6_ATTR_UNSPEC,
|
||||
|
||||
IOAM6_ATTR_NS_ID, /* u16 */
|
||||
IOAM6_ATTR_NS_DATA, /* u32 */
|
||||
IOAM6_ATTR_NS_DATA_WIDE,/* u64 */
|
||||
|
||||
#define IOAM6_MAX_SCHEMA_DATA_LEN (255 * 4)
|
||||
IOAM6_ATTR_SC_ID, /* u32 */
|
||||
IOAM6_ATTR_SC_DATA, /* Binary */
|
||||
IOAM6_ATTR_SC_NONE, /* Flag */
|
||||
|
||||
IOAM6_ATTR_PAD,
|
||||
|
||||
__IOAM6_ATTR_MAX,
|
||||
};
|
||||
|
||||
#define IOAM6_ATTR_MAX (__IOAM6_ATTR_MAX - 1)
|
||||
|
||||
enum {
|
||||
IOAM6_CMD_UNSPEC,
|
||||
|
||||
IOAM6_CMD_ADD_NAMESPACE,
|
||||
IOAM6_CMD_DEL_NAMESPACE,
|
||||
IOAM6_CMD_DUMP_NAMESPACES,
|
||||
|
||||
IOAM6_CMD_ADD_SCHEMA,
|
||||
IOAM6_CMD_DEL_SCHEMA,
|
||||
IOAM6_CMD_DUMP_SCHEMAS,
|
||||
|
||||
IOAM6_CMD_NS_SET_SCHEMA,
|
||||
|
||||
__IOAM6_CMD_MAX,
|
||||
};
|
||||
|
||||
#define IOAM6_CMD_MAX (__IOAM6_CMD_MAX - 1)
|
||||
|
||||
#endif /* _LINUX_IOAM6_GENL_H */
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
/*
|
||||
* IPv6 IOAM Lightweight Tunnel API
|
||||
*
|
||||
* Author:
|
||||
* Justin Iurman <justin.iurman@uliege.be>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_IOAM6_IPTUNNEL_H
|
||||
#define _LINUX_IOAM6_IPTUNNEL_H
|
||||
|
||||
/* Encap modes:
|
||||
* - inline: direct insertion
|
||||
* - encap: ip6ip6 encapsulation
|
||||
* - auto: __inline__ for local packets, encap for in-transit packets
|
||||
*/
|
||||
enum {
|
||||
__IOAM6_IPTUNNEL_MODE_MIN,
|
||||
|
||||
IOAM6_IPTUNNEL_MODE_INLINE,
|
||||
IOAM6_IPTUNNEL_MODE_ENCAP,
|
||||
IOAM6_IPTUNNEL_MODE_AUTO,
|
||||
|
||||
__IOAM6_IPTUNNEL_MODE_MAX,
|
||||
};
|
||||
|
||||
#define IOAM6_IPTUNNEL_MODE_MIN (__IOAM6_IPTUNNEL_MODE_MIN + 1)
|
||||
#define IOAM6_IPTUNNEL_MODE_MAX (__IOAM6_IPTUNNEL_MODE_MAX - 1)
|
||||
|
||||
enum {
|
||||
IOAM6_IPTUNNEL_UNSPEC,
|
||||
|
||||
/* Encap mode */
|
||||
IOAM6_IPTUNNEL_MODE, /* u8 */
|
||||
|
||||
/* Tunnel dst address.
|
||||
* For encap,auto modes.
|
||||
*/
|
||||
IOAM6_IPTUNNEL_DST, /* struct in6_addr */
|
||||
|
||||
/* IOAM Trace Header */
|
||||
IOAM6_IPTUNNEL_TRACE, /* struct ioam6_trace_hdr */
|
||||
|
||||
__IOAM6_IPTUNNEL_MAX,
|
||||
};
|
||||
|
||||
#define IOAM6_IPTUNNEL_MAX (__IOAM6_IPTUNNEL_MAX - 1)
|
||||
|
||||
#endif /* _LINUX_IOAM6_IPTUNNEL_H */
|
||||
|
|
@ -169,7 +169,6 @@ enum
|
|||
IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
|
||||
IPV4_DEVCONF_DROP_GRATUITOUS_ARP,
|
||||
IPV4_DEVCONF_BC_FORWARDING,
|
||||
IPV4_DEVCONF_ARP_EVICT_NOCARRIER,
|
||||
__IPV4_DEVCONF_MAX
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@
|
|||
#define _LINUX_KERNEL_H
|
||||
|
||||
#include <linux/sysinfo.h>
|
||||
#include <linux/const.h>
|
||||
|
||||
/*
|
||||
* 'kernel.h' contains some often-used function prototypes etc
|
||||
*/
|
||||
#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
|
||||
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
|
||||
|
||||
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||
|
||||
#endif /* _LINUX_KERNEL_H */
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ enum {
|
|||
L2TP_ATTR_VLAN_ID, /* u16 (not used) */
|
||||
L2TP_ATTR_COOKIE, /* 0, 4 or 8 bytes */
|
||||
L2TP_ATTR_PEER_COOKIE, /* 0, 4 or 8 bytes */
|
||||
L2TP_ATTR_DEBUG, /* u32, enum l2tp_debug_flags (not used) */
|
||||
L2TP_ATTR_DEBUG, /* u32, enum l2tp_debug_flags */
|
||||
L2TP_ATTR_RECV_SEQ, /* u8 */
|
||||
L2TP_ATTR_SEND_SEQ, /* u8 */
|
||||
L2TP_ATTR_LNS_MODE, /* u8 */
|
||||
|
|
@ -144,8 +144,6 @@ enum {
|
|||
L2TP_ATTR_RX_OOS_PACKETS, /* u64 */
|
||||
L2TP_ATTR_RX_ERRORS, /* u64 */
|
||||
L2TP_ATTR_STATS_PAD,
|
||||
L2TP_ATTR_RX_COOKIE_DISCARDS, /* u64 */
|
||||
L2TP_ATTR_RX_INVALID, /* u64 */
|
||||
__L2TP_ATTR_STATS_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -179,9 +177,7 @@ enum l2tp_seqmode {
|
|||
};
|
||||
|
||||
/**
|
||||
* enum l2tp_debug_flags - debug message categories for L2TP tunnels/sessions.
|
||||
*
|
||||
* Unused.
|
||||
* enum l2tp_debug_flags - debug message categories for L2TP tunnels/sessions
|
||||
*
|
||||
* @L2TP_MSG_DEBUG: verbose debug (if compiled in)
|
||||
* @L2TP_MSG_CONTROL: userspace - kernel interface
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ enum lwtunnel_encap_types {
|
|||
LWTUNNEL_ENCAP_BPF,
|
||||
LWTUNNEL_ENCAP_SEG6_LOCAL,
|
||||
LWTUNNEL_ENCAP_RPL,
|
||||
LWTUNNEL_ENCAP_IOAM6,
|
||||
__LWTUNNEL_ENCAP_MAX,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -94,9 +94,7 @@
|
|||
#define BALLOON_KVM_MAGIC 0x13661366
|
||||
#define ZSMALLOC_MAGIC 0x58295829
|
||||
#define DMA_BUF_MAGIC 0x444d4142 /* "DMAB" */
|
||||
#define DEVMEM_MAGIC 0x454d444d /* "DMEM" */
|
||||
#define Z3FOLD_MAGIC 0x33
|
||||
#define PPC_CMM_MAGIC 0xc7571590
|
||||
#define SECRETMEM_MAGIC 0x5345434d /* "SECM" */
|
||||
|
||||
#endif /* __LINUX_MAGIC_H__ */
|
||||
|
|
|
|||
|
|
@ -1,229 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
#ifndef _MPTCP_H
|
||||
#define _MPTCP_H
|
||||
|
||||
#include <linux/const.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/in.h> /* for sockaddr_in */
|
||||
#include <linux/in6.h> /* for sockaddr_in6 */
|
||||
#include <linux/socket.h> /* for sockaddr_storage and sa_family */
|
||||
|
||||
#include <sys/socket.h> /* for struct sockaddr */
|
||||
|
||||
#define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0)
|
||||
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
|
||||
#define MPTCP_SUBFLOW_FLAG_JOIN_REM _BITUL(2)
|
||||
#define MPTCP_SUBFLOW_FLAG_JOIN_LOC _BITUL(3)
|
||||
#define MPTCP_SUBFLOW_FLAG_BKUP_REM _BITUL(4)
|
||||
#define MPTCP_SUBFLOW_FLAG_BKUP_LOC _BITUL(5)
|
||||
#define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED _BITUL(6)
|
||||
#define MPTCP_SUBFLOW_FLAG_CONNECTED _BITUL(7)
|
||||
#define MPTCP_SUBFLOW_FLAG_MAPVALID _BITUL(8)
|
||||
|
||||
enum {
|
||||
MPTCP_SUBFLOW_ATTR_UNSPEC,
|
||||
MPTCP_SUBFLOW_ATTR_TOKEN_REM,
|
||||
MPTCP_SUBFLOW_ATTR_TOKEN_LOC,
|
||||
MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ,
|
||||
MPTCP_SUBFLOW_ATTR_MAP_SEQ,
|
||||
MPTCP_SUBFLOW_ATTR_MAP_SFSEQ,
|
||||
MPTCP_SUBFLOW_ATTR_SSN_OFFSET,
|
||||
MPTCP_SUBFLOW_ATTR_MAP_DATALEN,
|
||||
MPTCP_SUBFLOW_ATTR_FLAGS,
|
||||
MPTCP_SUBFLOW_ATTR_ID_REM,
|
||||
MPTCP_SUBFLOW_ATTR_ID_LOC,
|
||||
MPTCP_SUBFLOW_ATTR_PAD,
|
||||
__MPTCP_SUBFLOW_ATTR_MAX
|
||||
};
|
||||
|
||||
#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1)
|
||||
|
||||
/* netlink interface */
|
||||
#define MPTCP_PM_NAME "mptcp_pm"
|
||||
#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"
|
||||
#define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events"
|
||||
#define MPTCP_PM_VER 0x1
|
||||
|
||||
/*
|
||||
* ATTR types defined for MPTCP
|
||||
*/
|
||||
enum {
|
||||
MPTCP_PM_ATTR_UNSPEC,
|
||||
|
||||
MPTCP_PM_ATTR_ADDR, /* nested address */
|
||||
MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */
|
||||
MPTCP_PM_ATTR_SUBFLOWS, /* u32 */
|
||||
|
||||
__MPTCP_PM_ATTR_MAX
|
||||
};
|
||||
|
||||
#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1)
|
||||
|
||||
enum {
|
||||
MPTCP_PM_ADDR_ATTR_UNSPEC,
|
||||
|
||||
MPTCP_PM_ADDR_ATTR_FAMILY, /* u16 */
|
||||
MPTCP_PM_ADDR_ATTR_ID, /* u8 */
|
||||
MPTCP_PM_ADDR_ATTR_ADDR4, /* struct in_addr */
|
||||
MPTCP_PM_ADDR_ATTR_ADDR6, /* struct in6_addr */
|
||||
MPTCP_PM_ADDR_ATTR_PORT, /* u16 */
|
||||
MPTCP_PM_ADDR_ATTR_FLAGS, /* u32 */
|
||||
MPTCP_PM_ADDR_ATTR_IF_IDX, /* s32 */
|
||||
|
||||
__MPTCP_PM_ADDR_ATTR_MAX
|
||||
};
|
||||
|
||||
#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1)
|
||||
|
||||
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
|
||||
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
|
||||
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
|
||||
#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
|
||||
|
||||
enum {
|
||||
MPTCP_PM_CMD_UNSPEC,
|
||||
|
||||
MPTCP_PM_CMD_ADD_ADDR,
|
||||
MPTCP_PM_CMD_DEL_ADDR,
|
||||
MPTCP_PM_CMD_GET_ADDR,
|
||||
MPTCP_PM_CMD_FLUSH_ADDRS,
|
||||
MPTCP_PM_CMD_SET_LIMITS,
|
||||
MPTCP_PM_CMD_GET_LIMITS,
|
||||
MPTCP_PM_CMD_SET_FLAGS,
|
||||
|
||||
__MPTCP_PM_CMD_AFTER_LAST
|
||||
};
|
||||
|
||||
#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)
|
||||
#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1)
|
||||
|
||||
struct mptcp_info {
|
||||
__u8 mptcpi_subflows;
|
||||
__u8 mptcpi_add_addr_signal;
|
||||
__u8 mptcpi_add_addr_accepted;
|
||||
__u8 mptcpi_subflows_max;
|
||||
__u8 mptcpi_add_addr_signal_max;
|
||||
__u8 mptcpi_add_addr_accepted_max;
|
||||
__u32 mptcpi_flags;
|
||||
__u32 mptcpi_token;
|
||||
__u64 mptcpi_write_seq;
|
||||
__u64 mptcpi_snd_una;
|
||||
__u64 mptcpi_rcv_nxt;
|
||||
__u8 mptcpi_local_addr_used;
|
||||
__u8 mptcpi_local_addr_max;
|
||||
__u8 mptcpi_csum_enabled;
|
||||
};
|
||||
|
||||
/*
|
||||
* MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6,
|
||||
* sport, dport
|
||||
* A new MPTCP connection has been created. It is the good time to allocate
|
||||
* memory and send ADD_ADDR if needed. Depending on the traffic-patterns
|
||||
* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent.
|
||||
*
|
||||
* MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6,
|
||||
* sport, dport
|
||||
* A MPTCP connection is established (can start new subflows).
|
||||
*
|
||||
* MPTCP_EVENT_CLOSED: token
|
||||
* A MPTCP connection has stopped.
|
||||
*
|
||||
* MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport]
|
||||
* A new address has been announced by the peer.
|
||||
*
|
||||
* MPTCP_EVENT_REMOVED: token, rem_id
|
||||
* An address has been lost by the peer.
|
||||
*
|
||||
* MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6,
|
||||
* daddr4 | daddr6, sport, dport, backup,
|
||||
* if_idx [, error]
|
||||
* A new subflow has been established. 'error' should not be set.
|
||||
*
|
||||
* MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6,
|
||||
* sport, dport, backup, if_idx [, error]
|
||||
* A subflow has been closed. An error (copy of sk_err) could be set if an
|
||||
* error has been detected for this subflow.
|
||||
*
|
||||
* MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6,
|
||||
* sport, dport, backup, if_idx [, error]
|
||||
* The priority of a subflow has changed. 'error' should not be set.
|
||||
*/
|
||||
enum mptcp_event_type {
|
||||
MPTCP_EVENT_UNSPEC = 0,
|
||||
MPTCP_EVENT_CREATED = 1,
|
||||
MPTCP_EVENT_ESTABLISHED = 2,
|
||||
MPTCP_EVENT_CLOSED = 3,
|
||||
|
||||
MPTCP_EVENT_ANNOUNCED = 6,
|
||||
MPTCP_EVENT_REMOVED = 7,
|
||||
|
||||
MPTCP_EVENT_SUB_ESTABLISHED = 10,
|
||||
MPTCP_EVENT_SUB_CLOSED = 11,
|
||||
|
||||
MPTCP_EVENT_SUB_PRIORITY = 13,
|
||||
};
|
||||
|
||||
enum mptcp_event_attr {
|
||||
MPTCP_ATTR_UNSPEC = 0,
|
||||
|
||||
MPTCP_ATTR_TOKEN, /* u32 */
|
||||
MPTCP_ATTR_FAMILY, /* u16 */
|
||||
MPTCP_ATTR_LOC_ID, /* u8 */
|
||||
MPTCP_ATTR_REM_ID, /* u8 */
|
||||
MPTCP_ATTR_SADDR4, /* be32 */
|
||||
MPTCP_ATTR_SADDR6, /* struct in6_addr */
|
||||
MPTCP_ATTR_DADDR4, /* be32 */
|
||||
MPTCP_ATTR_DADDR6, /* struct in6_addr */
|
||||
MPTCP_ATTR_SPORT, /* be16 */
|
||||
MPTCP_ATTR_DPORT, /* be16 */
|
||||
MPTCP_ATTR_BACKUP, /* u8 */
|
||||
MPTCP_ATTR_ERROR, /* u8 */
|
||||
MPTCP_ATTR_FLAGS, /* u16 */
|
||||
MPTCP_ATTR_TIMEOUT, /* u32 */
|
||||
MPTCP_ATTR_IF_IDX, /* s32 */
|
||||
MPTCP_ATTR_RESET_REASON,/* u32 */
|
||||
MPTCP_ATTR_RESET_FLAGS, /* u32 */
|
||||
|
||||
__MPTCP_ATTR_AFTER_LAST
|
||||
};
|
||||
|
||||
#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1)
|
||||
|
||||
/* MPTCP Reset reason codes, rfc8684 */
|
||||
#define MPTCP_RST_EUNSPEC 0
|
||||
#define MPTCP_RST_EMPTCP 1
|
||||
#define MPTCP_RST_ERESOURCE 2
|
||||
#define MPTCP_RST_EPROHIBIT 3
|
||||
#define MPTCP_RST_EWQ2BIG 4
|
||||
#define MPTCP_RST_EBADPERF 5
|
||||
#define MPTCP_RST_EMIDDLEBOX 6
|
||||
|
||||
struct mptcp_subflow_data {
|
||||
__u32 size_subflow_data; /* size of this structure in userspace */
|
||||
__u32 num_subflows; /* must be 0, set by kernel */
|
||||
__u32 size_kernel; /* must be 0, set by kernel */
|
||||
__u32 size_user; /* size of one element in data[] */
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
struct mptcp_subflow_addrs {
|
||||
union {
|
||||
__kernel_sa_family_t sa_family;
|
||||
struct sockaddr sa_local;
|
||||
struct sockaddr_in sin_local;
|
||||
struct sockaddr_in6 sin6_local;
|
||||
struct __kernel_sockaddr_storage ss_local;
|
||||
};
|
||||
union {
|
||||
struct sockaddr sa_remote;
|
||||
struct sockaddr_in sin_remote;
|
||||
struct sockaddr_in6 sin6_remote;
|
||||
struct __kernel_sockaddr_storage ss_remote;
|
||||
};
|
||||
};
|
||||
|
||||
/* MPTCP socket options */
|
||||
#define MPTCP_INFO 1
|
||||
#define MPTCP_TCPINFO 2
|
||||
#define MPTCP_SUBFLOW_ADDRS 3
|
||||
|
||||
#endif /* _MPTCP_H */
|
||||
|
|
@ -29,9 +29,6 @@ enum {
|
|||
NDA_LINK_NETNSID,
|
||||
NDA_SRC_VNI,
|
||||
NDA_PROTOCOL, /* Originator of entry */
|
||||
NDA_NH_ID,
|
||||
NDA_FDB_EXT_ATTRS,
|
||||
NDA_FLAGS_EXT,
|
||||
__NDA_MAX
|
||||
};
|
||||
|
||||
|
|
@ -41,16 +38,14 @@ enum {
|
|||
* Neighbor Cache Entry Flags
|
||||
*/
|
||||
|
||||
#define NTF_USE (1 << 0)
|
||||
#define NTF_SELF (1 << 1)
|
||||
#define NTF_MASTER (1 << 2)
|
||||
#define NTF_PROXY (1 << 3) /* == ATF_PUBL */
|
||||
#define NTF_EXT_LEARNED (1 << 4)
|
||||
#define NTF_OFFLOADED (1 << 5)
|
||||
#define NTF_STICKY (1 << 6)
|
||||
#define NTF_ROUTER (1 << 7)
|
||||
/* Extended flags under NDA_FLAGS_EXT: */
|
||||
#define NTF_EXT_MANAGED (1 << 0)
|
||||
#define NTF_USE 0x01
|
||||
#define NTF_SELF 0x02
|
||||
#define NTF_MASTER 0x04
|
||||
#define NTF_PROXY 0x08 /* == ATF_PUBL */
|
||||
#define NTF_EXT_LEARNED 0x10
|
||||
#define NTF_OFFLOADED 0x20
|
||||
#define NTF_STICKY 0x40
|
||||
#define NTF_ROUTER 0x80
|
||||
|
||||
/*
|
||||
* Neighbor Cache Entry States.
|
||||
|
|
@ -68,22 +63,9 @@ enum {
|
|||
#define NUD_PERMANENT 0x80
|
||||
#define NUD_NONE 0x00
|
||||
|
||||
/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change and make no
|
||||
* address resolution or NUD.
|
||||
*
|
||||
* NUD_PERMANENT also cannot be deleted by garbage collectors. This holds true
|
||||
* for dynamic entries with NTF_EXT_LEARNED flag as well. However, upon carrier
|
||||
* down event, NUD_PERMANENT entries are not flushed whereas NTF_EXT_LEARNED
|
||||
* flagged entries explicitly are (which is also consistent with the routing
|
||||
* subsystem).
|
||||
*
|
||||
* When NTF_EXT_LEARNED is set for a bridge fdb entry the different cache entry
|
||||
* states don't make sense and thus are ignored. Such entries don't age and
|
||||
* can roam.
|
||||
*
|
||||
* NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf
|
||||
* of a user space control plane, and automatically refreshed so that (if
|
||||
* possible) they remain in NUD_REACHABLE state.
|
||||
/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change
|
||||
and make no address resolution or NUD.
|
||||
NUD_PERMANENT also cannot be deleted by garbage collectors.
|
||||
*/
|
||||
|
||||
struct nda_cacheinfo {
|
||||
|
|
@ -189,27 +171,4 @@ enum {
|
|||
};
|
||||
#define NDTA_MAX (__NDTA_MAX - 1)
|
||||
|
||||
/* FDB activity notification bits used in NFEA_ACTIVITY_NOTIFY:
|
||||
* - FDB_NOTIFY_BIT - notify on activity/expire for any entry
|
||||
* - FDB_NOTIFY_INACTIVE_BIT - mark as inactive to avoid multiple notifications
|
||||
*/
|
||||
enum {
|
||||
FDB_NOTIFY_BIT = (1 << 0),
|
||||
FDB_NOTIFY_INACTIVE_BIT = (1 << 1)
|
||||
};
|
||||
|
||||
/* embedded into NDA_FDB_EXT_ATTRS:
|
||||
* [NDA_FDB_EXT_ATTRS] = {
|
||||
* [NFEA_ACTIVITY_NOTIFY]
|
||||
* ...
|
||||
* }
|
||||
*/
|
||||
enum {
|
||||
NFEA_UNSPEC,
|
||||
NFEA_ACTIVITY_NOTIFY,
|
||||
NFEA_DONT_REFRESH,
|
||||
__NFEA_MAX
|
||||
};
|
||||
#define NFEA_MAX (__NFEA_MAX - 1)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -43,13 +43,11 @@ enum nf_inet_hooks {
|
|||
NF_INET_FORWARD,
|
||||
NF_INET_LOCAL_OUT,
|
||||
NF_INET_POST_ROUTING,
|
||||
NF_INET_NUMHOOKS,
|
||||
NF_INET_INGRESS = NF_INET_NUMHOOKS,
|
||||
NF_INET_NUMHOOKS
|
||||
};
|
||||
|
||||
enum nf_dev_hooks {
|
||||
NF_NETDEV_INGRESS,
|
||||
NF_NETDEV_EGRESS,
|
||||
NF_NETDEV_NUMHOOKS
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -92,11 +92,11 @@ enum {
|
|||
/* Reserve empty slots */
|
||||
IPSET_ATTR_CADT_MAX = 16,
|
||||
/* Create-only specific attributes */
|
||||
IPSET_ATTR_INITVAL, /* was unused IPSET_ATTR_GC */
|
||||
IPSET_ATTR_GC,
|
||||
IPSET_ATTR_HASHSIZE,
|
||||
IPSET_ATTR_MAXELEM,
|
||||
IPSET_ATTR_NETMASK,
|
||||
IPSET_ATTR_BUCKETSIZE, /* was unused IPSET_ATTR_PROBES */
|
||||
IPSET_ATTR_PROBES,
|
||||
IPSET_ATTR_RESIZE,
|
||||
IPSET_ATTR_SIZE,
|
||||
/* Kernel-only */
|
||||
|
|
@ -214,8 +214,6 @@ enum ipset_cadt_flags {
|
|||
enum ipset_create_flags {
|
||||
IPSET_CREATE_FLAG_BIT_FORCEADD = 0,
|
||||
IPSET_CREATE_FLAG_FORCEADD = (1 << IPSET_CREATE_FLAG_BIT_FORCEADD),
|
||||
IPSET_CREATE_FLAG_BIT_BUCKETSIZE = 1,
|
||||
IPSET_CREATE_FLAG_BUCKETSIZE = (1 << IPSET_CREATE_FLAG_BIT_BUCKETSIZE),
|
||||
IPSET_CREATE_FLAG_BIT_MAX = 7,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _X_TABLES_H
|
||||
#define _X_TABLES_H
|
||||
#include <linux/const.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define XT_FUNCTION_MAXNAMELEN 30
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#ifndef __LINUX_NETLINK_H
|
||||
#define __LINUX_NETLINK_H
|
||||
|
||||
#include <linux/const.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/socket.h> /* for __kernel_sa_family_t */
|
||||
#include <linux/types.h>
|
||||
|
||||
|
|
@ -91,10 +91,9 @@ struct nlmsghdr {
|
|||
#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
|
||||
#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)
|
||||
#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
|
||||
#define NLMSG_DATA(nlh) ((void *)(((char *)nlh) + NLMSG_HDRLEN))
|
||||
#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
|
||||
#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
|
||||
(struct nlmsghdr *)(((char *)(nlh)) + \
|
||||
NLMSG_ALIGN((nlh)->nlmsg_len)))
|
||||
(struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
|
||||
#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
|
||||
(nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
|
||||
(nlh)->nlmsg_len <= (len))
|
||||
|
|
@ -130,7 +129,6 @@ struct nlmsgerr {
|
|||
* @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to
|
||||
* be used - in the success case - to identify a created
|
||||
* object or operation or similar (binary)
|
||||
* @NLMSGERR_ATTR_POLICY: policy for a rejected attribute
|
||||
* @__NLMSGERR_ATTR_MAX: number of attributes
|
||||
* @NLMSGERR_ATTR_MAX: highest attribute number
|
||||
*/
|
||||
|
|
@ -139,7 +137,6 @@ enum nlmsgerr_attrs {
|
|||
NLMSGERR_ATTR_MSG,
|
||||
NLMSGERR_ATTR_OFFS,
|
||||
NLMSGERR_ATTR_COOKIE,
|
||||
NLMSGERR_ATTR_POLICY,
|
||||
|
||||
__NLMSGERR_ATTR_MAX,
|
||||
NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1
|
||||
|
|
@ -248,109 +245,4 @@ struct nla_bitfield32 {
|
|||
__u32 selector;
|
||||
};
|
||||
|
||||
/*
|
||||
* policy descriptions - it's specific to each family how this is used
|
||||
* Normally, it should be retrieved via a dump inside another attribute
|
||||
* specifying where it applies.
|
||||
*/
|
||||
|
||||
/**
|
||||
* enum netlink_attribute_type - type of an attribute
|
||||
* @NL_ATTR_TYPE_INVALID: unused
|
||||
* @NL_ATTR_TYPE_FLAG: flag attribute (present/not present)
|
||||
* @NL_ATTR_TYPE_U8: 8-bit unsigned attribute
|
||||
* @NL_ATTR_TYPE_U16: 16-bit unsigned attribute
|
||||
* @NL_ATTR_TYPE_U32: 32-bit unsigned attribute
|
||||
* @NL_ATTR_TYPE_U64: 64-bit unsigned attribute
|
||||
* @NL_ATTR_TYPE_S8: 8-bit signed attribute
|
||||
* @NL_ATTR_TYPE_S16: 16-bit signed attribute
|
||||
* @NL_ATTR_TYPE_S32: 32-bit signed attribute
|
||||
* @NL_ATTR_TYPE_S64: 64-bit signed attribute
|
||||
* @NL_ATTR_TYPE_BINARY: binary data, min/max length may be specified
|
||||
* @NL_ATTR_TYPE_STRING: string, min/max length may be specified
|
||||
* @NL_ATTR_TYPE_NUL_STRING: NUL-terminated string,
|
||||
* min/max length may be specified
|
||||
* @NL_ATTR_TYPE_NESTED: nested, i.e. the content of this attribute
|
||||
* consists of sub-attributes. The nested policy and maxtype
|
||||
* inside may be specified.
|
||||
* @NL_ATTR_TYPE_NESTED_ARRAY: nested array, i.e. the content of this
|
||||
* attribute contains sub-attributes whose type is irrelevant
|
||||
* (just used to separate the array entries) and each such array
|
||||
* entry has attributes again, the policy for those inner ones
|
||||
* and the corresponding maxtype may be specified.
|
||||
* @NL_ATTR_TYPE_BITFIELD32: &struct nla_bitfield32 attribute
|
||||
*/
|
||||
enum netlink_attribute_type {
|
||||
NL_ATTR_TYPE_INVALID,
|
||||
|
||||
NL_ATTR_TYPE_FLAG,
|
||||
|
||||
NL_ATTR_TYPE_U8,
|
||||
NL_ATTR_TYPE_U16,
|
||||
NL_ATTR_TYPE_U32,
|
||||
NL_ATTR_TYPE_U64,
|
||||
|
||||
NL_ATTR_TYPE_S8,
|
||||
NL_ATTR_TYPE_S16,
|
||||
NL_ATTR_TYPE_S32,
|
||||
NL_ATTR_TYPE_S64,
|
||||
|
||||
NL_ATTR_TYPE_BINARY,
|
||||
NL_ATTR_TYPE_STRING,
|
||||
NL_ATTR_TYPE_NUL_STRING,
|
||||
|
||||
NL_ATTR_TYPE_NESTED,
|
||||
NL_ATTR_TYPE_NESTED_ARRAY,
|
||||
|
||||
NL_ATTR_TYPE_BITFIELD32,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum netlink_policy_type_attr - policy type attributes
|
||||
* @NL_POLICY_TYPE_ATTR_UNSPEC: unused
|
||||
* @NL_POLICY_TYPE_ATTR_TYPE: type of the attribute,
|
||||
* &enum netlink_attribute_type (U32)
|
||||
* @NL_POLICY_TYPE_ATTR_MIN_VALUE_S: minimum value for signed
|
||||
* integers (S64)
|
||||
* @NL_POLICY_TYPE_ATTR_MAX_VALUE_S: maximum value for signed
|
||||
* integers (S64)
|
||||
* @NL_POLICY_TYPE_ATTR_MIN_VALUE_U: minimum value for unsigned
|
||||
* integers (U64)
|
||||
* @NL_POLICY_TYPE_ATTR_MAX_VALUE_U: maximum value for unsigned
|
||||
* integers (U64)
|
||||
* @NL_POLICY_TYPE_ATTR_MIN_LENGTH: minimum length for binary
|
||||
* attributes, no minimum if not given (U32)
|
||||
* @NL_POLICY_TYPE_ATTR_MAX_LENGTH: maximum length for binary
|
||||
* attributes, no maximum if not given (U32)
|
||||
* @NL_POLICY_TYPE_ATTR_POLICY_IDX: sub policy for nested and
|
||||
* nested array types (U32)
|
||||
* @NL_POLICY_TYPE_ATTR_POLICY_MAXTYPE: maximum sub policy
|
||||
* attribute for nested and nested array types, this can
|
||||
* in theory be < the size of the policy pointed to by
|
||||
* the index, if limited inside the nesting (U32)
|
||||
* @NL_POLICY_TYPE_ATTR_BITFIELD32_MASK: valid mask for the
|
||||
* bitfield32 type (U32)
|
||||
* @NL_POLICY_TYPE_ATTR_MASK: mask of valid bits for unsigned integers (U64)
|
||||
* @NL_POLICY_TYPE_ATTR_PAD: pad attribute for 64-bit alignment
|
||||
*/
|
||||
enum netlink_policy_type_attr {
|
||||
NL_POLICY_TYPE_ATTR_UNSPEC,
|
||||
NL_POLICY_TYPE_ATTR_TYPE,
|
||||
NL_POLICY_TYPE_ATTR_MIN_VALUE_S,
|
||||
NL_POLICY_TYPE_ATTR_MAX_VALUE_S,
|
||||
NL_POLICY_TYPE_ATTR_MIN_VALUE_U,
|
||||
NL_POLICY_TYPE_ATTR_MAX_VALUE_U,
|
||||
NL_POLICY_TYPE_ATTR_MIN_LENGTH,
|
||||
NL_POLICY_TYPE_ATTR_MAX_LENGTH,
|
||||
NL_POLICY_TYPE_ATTR_POLICY_IDX,
|
||||
NL_POLICY_TYPE_ATTR_POLICY_MAXTYPE,
|
||||
NL_POLICY_TYPE_ATTR_BITFIELD32_MASK,
|
||||
NL_POLICY_TYPE_ATTR_PAD,
|
||||
NL_POLICY_TYPE_ATTR_MASK,
|
||||
|
||||
/* keep last */
|
||||
__NL_POLICY_TYPE_ATTR_MAX,
|
||||
NL_POLICY_TYPE_ATTR_MAX = __NL_POLICY_TYPE_ATTR_MAX - 1
|
||||
};
|
||||
|
||||
#endif /* __LINUX_NETLINK_H */
|
||||
|
|
|
|||
|
|
@ -21,10 +21,7 @@ struct nexthop_grp {
|
|||
};
|
||||
|
||||
enum {
|
||||
NEXTHOP_GRP_TYPE_MPATH, /* hash-threshold nexthop group
|
||||
* default type if not specified
|
||||
*/
|
||||
NEXTHOP_GRP_TYPE_RES, /* resilient nexthop group */
|
||||
NEXTHOP_GRP_TYPE_MPATH, /* default type if not specified */
|
||||
__NEXTHOP_GRP_TYPE_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -52,53 +49,8 @@ enum {
|
|||
NHA_GROUPS, /* flag; only return nexthop groups in dump */
|
||||
NHA_MASTER, /* u32; only return nexthops with given master dev */
|
||||
|
||||
NHA_FDB, /* flag; nexthop belongs to a bridge fdb */
|
||||
/* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */
|
||||
|
||||
/* nested; resilient nexthop group attributes */
|
||||
NHA_RES_GROUP,
|
||||
/* nested; nexthop bucket attributes */
|
||||
NHA_RES_BUCKET,
|
||||
|
||||
__NHA_MAX,
|
||||
};
|
||||
|
||||
#define NHA_MAX (__NHA_MAX - 1)
|
||||
|
||||
enum {
|
||||
NHA_RES_GROUP_UNSPEC,
|
||||
/* Pad attribute for 64-bit alignment. */
|
||||
NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC,
|
||||
|
||||
/* u16; number of nexthop buckets in a resilient nexthop group */
|
||||
NHA_RES_GROUP_BUCKETS,
|
||||
/* clock_t as u32; nexthop bucket idle timer (per-group) */
|
||||
NHA_RES_GROUP_IDLE_TIMER,
|
||||
/* clock_t as u32; nexthop unbalanced timer */
|
||||
NHA_RES_GROUP_UNBALANCED_TIMER,
|
||||
/* clock_t as u64; nexthop unbalanced time */
|
||||
NHA_RES_GROUP_UNBALANCED_TIME,
|
||||
|
||||
__NHA_RES_GROUP_MAX,
|
||||
};
|
||||
|
||||
#define NHA_RES_GROUP_MAX (__NHA_RES_GROUP_MAX - 1)
|
||||
|
||||
enum {
|
||||
NHA_RES_BUCKET_UNSPEC,
|
||||
/* Pad attribute for 64-bit alignment. */
|
||||
NHA_RES_BUCKET_PAD = NHA_RES_BUCKET_UNSPEC,
|
||||
|
||||
/* u16; nexthop bucket index */
|
||||
NHA_RES_BUCKET_INDEX,
|
||||
/* clock_t as u64; nexthop bucket idle time */
|
||||
NHA_RES_BUCKET_IDLE_TIME,
|
||||
/* u32; nexthop id assigned to the nexthop bucket */
|
||||
NHA_RES_BUCKET_NH_ID,
|
||||
|
||||
__NHA_RES_BUCKET_MAX,
|
||||
};
|
||||
|
||||
#define NHA_RES_BUCKET_MAX (__NHA_RES_BUCKET_MAX - 1)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ enum {
|
|||
__TCA_ACT_MAX
|
||||
};
|
||||
|
||||
/* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */
|
||||
#define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for
|
||||
* actions stats.
|
||||
*/
|
||||
|
|
@ -135,7 +134,6 @@ enum tca_id {
|
|||
TCA_ID_CTINFO,
|
||||
TCA_ID_MPLS,
|
||||
TCA_ID_CT,
|
||||
TCA_ID_GATE,
|
||||
/* other actions go here */
|
||||
__TCA_ID_MAX = 255
|
||||
};
|
||||
|
|
@ -191,8 +189,6 @@ enum {
|
|||
TCA_POLICE_PAD,
|
||||
TCA_POLICE_RATE64,
|
||||
TCA_POLICE_PEAKRATE64,
|
||||
TCA_POLICE_PKTRATE64,
|
||||
TCA_POLICE_PKTBURST64,
|
||||
__TCA_POLICE_MAX
|
||||
#define TCA_POLICE_RESULT TCA_POLICE_RESULT
|
||||
};
|
||||
|
|
@ -579,11 +575,6 @@ enum {
|
|||
TCA_FLOWER_KEY_CT_LABELS, /* u128 */
|
||||
TCA_FLOWER_KEY_CT_LABELS_MASK, /* u128 */
|
||||
|
||||
TCA_FLOWER_KEY_MPLS_OPTS,
|
||||
|
||||
TCA_FLOWER_KEY_HASH, /* u32 */
|
||||
TCA_FLOWER_KEY_HASH_MASK, /* u32 */
|
||||
|
||||
__TCA_FLOWER_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -594,9 +585,6 @@ enum {
|
|||
TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED = 1 << 1, /* Part of an existing connection. */
|
||||
TCA_FLOWER_KEY_CT_FLAGS_RELATED = 1 << 2, /* Related to an established connection. */
|
||||
TCA_FLOWER_KEY_CT_FLAGS_TRACKED = 1 << 3, /* Conntrack has occurred. */
|
||||
TCA_FLOWER_KEY_CT_FLAGS_INVALID = 1 << 4, /* Conntrack is invalid. */
|
||||
TCA_FLOWER_KEY_CT_FLAGS_REPLY = 1 << 5, /* Packet is in the reply direction. */
|
||||
__TCA_FLOWER_KEY_CT_FLAGS_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -651,27 +639,6 @@ enum {
|
|||
#define TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX \
|
||||
(__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX - 1)
|
||||
|
||||
enum {
|
||||
TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC,
|
||||
TCA_FLOWER_KEY_MPLS_OPTS_LSE,
|
||||
__TCA_FLOWER_KEY_MPLS_OPTS_MAX,
|
||||
};
|
||||
|
||||
#define TCA_FLOWER_KEY_MPLS_OPTS_MAX (__TCA_FLOWER_KEY_MPLS_OPTS_MAX - 1)
|
||||
|
||||
enum {
|
||||
TCA_FLOWER_KEY_MPLS_OPT_LSE_UNSPEC,
|
||||
TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH,
|
||||
TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL,
|
||||
TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS,
|
||||
TCA_FLOWER_KEY_MPLS_OPT_LSE_TC,
|
||||
TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL,
|
||||
__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX,
|
||||
};
|
||||
|
||||
#define TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX \
|
||||
(__TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX - 1)
|
||||
|
||||
enum {
|
||||
TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT = (1 << 0),
|
||||
TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
|
||||
|
|
|
|||
|
|
@ -257,8 +257,6 @@ enum {
|
|||
TCA_RED_STAB,
|
||||
TCA_RED_MAX_P,
|
||||
TCA_RED_FLAGS, /* bitfield32 */
|
||||
TCA_RED_EARLY_DROP_BLOCK, /* u32 */
|
||||
TCA_RED_MARK_BLOCK, /* u32 */
|
||||
__TCA_RED_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -434,7 +432,6 @@ enum {
|
|||
TCA_HTB_RATE64,
|
||||
TCA_HTB_CEIL64,
|
||||
TCA_HTB_PAD,
|
||||
TCA_HTB_OFFLOAD,
|
||||
__TCA_HTB_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -827,8 +824,6 @@ struct tc_codel_xstats {
|
|||
|
||||
/* FQ_CODEL */
|
||||
|
||||
#define FQ_CODEL_QUANTUM_MAX (1 << 20)
|
||||
|
||||
enum {
|
||||
TCA_FQ_CODEL_UNSPEC,
|
||||
TCA_FQ_CODEL_TARGET,
|
||||
|
|
@ -840,8 +835,6 @@ enum {
|
|||
TCA_FQ_CODEL_CE_THRESHOLD,
|
||||
TCA_FQ_CODEL_DROP_BATCH_SIZE,
|
||||
TCA_FQ_CODEL_MEMORY_LIMIT,
|
||||
TCA_FQ_CODEL_CE_THRESHOLD_SELECTOR,
|
||||
TCA_FQ_CODEL_CE_THRESHOLD_MASK,
|
||||
__TCA_FQ_CODEL_MAX
|
||||
};
|
||||
|
||||
|
|
@ -920,10 +913,6 @@ enum {
|
|||
|
||||
TCA_FQ_TIMER_SLACK, /* timer slack */
|
||||
|
||||
TCA_FQ_HORIZON, /* time horizon in us */
|
||||
|
||||
TCA_FQ_HORIZON_DROP, /* drop packets beyond horizon, or cap their EDT */
|
||||
|
||||
__TCA_FQ_MAX
|
||||
};
|
||||
|
||||
|
|
@ -943,8 +932,6 @@ struct tc_fq_qd_stats {
|
|||
__u32 throttled_flows;
|
||||
__u32 unthrottle_latency_ns;
|
||||
__u64 ce_mark; /* packets above ce_threshold */
|
||||
__u64 horizon_drops;
|
||||
__u64 horizon_caps;
|
||||
};
|
||||
|
||||
/* Heavy-Hitter Filter */
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
/*
|
||||
* IPv6 RPL-SR implementation
|
||||
*
|
||||
* Author:
|
||||
* (C) 2020 Alexander Aring <alex.aring@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_RPL_H
|
||||
#define _LINUX_RPL_H
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/in6.h>
|
||||
|
||||
/*
|
||||
* RPL SR Header
|
||||
*/
|
||||
struct ipv6_rpl_sr_hdr {
|
||||
__u8 nexthdr;
|
||||
__u8 hdrlen;
|
||||
__u8 type;
|
||||
__u8 segments_left;
|
||||
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
||||
__u32 cmpre:4,
|
||||
cmpri:4,
|
||||
reserved:4,
|
||||
pad:4,
|
||||
reserved1:16;
|
||||
#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
__u32 cmpri:4,
|
||||
cmpre:4,
|
||||
pad:4,
|
||||
reserved:20;
|
||||
#else
|
||||
#error "Please fix <asm/byteorder.h>"
|
||||
#endif
|
||||
|
||||
union {
|
||||
struct in6_addr addr[0];
|
||||
__u8 data[0];
|
||||
} segments;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define rpl_segaddr segments.addr
|
||||
#define rpl_segdata segments.data
|
||||
|
||||
#endif
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
/*
|
||||
* IPv6 RPL-SR implementation
|
||||
*
|
||||
* Author:
|
||||
* (C) 2020 Alexander Aring <alex.aring@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_RPL_IPTUNNEL_H
|
||||
#define _LINUX_RPL_IPTUNNEL_H
|
||||
|
||||
enum {
|
||||
RPL_IPTUNNEL_UNSPEC,
|
||||
RPL_IPTUNNEL_SRH,
|
||||
__RPL_IPTUNNEL_MAX,
|
||||
};
|
||||
#define RPL_IPTUNNEL_MAX (__RPL_IPTUNNEL_MAX - 1)
|
||||
|
||||
#define RPL_IPTUNNEL_SRH_SIZE(srh) (((srh)->hdrlen + 1) << 3)
|
||||
|
||||
#endif
|
||||
|
|
@ -178,13 +178,6 @@ enum {
|
|||
RTM_GETVLAN,
|
||||
#define RTM_GETVLAN RTM_GETVLAN
|
||||
|
||||
RTM_NEWNEXTHOPBUCKET = 116,
|
||||
#define RTM_NEWNEXTHOPBUCKET RTM_NEWNEXTHOPBUCKET
|
||||
RTM_DELNEXTHOPBUCKET,
|
||||
#define RTM_DELNEXTHOPBUCKET RTM_DELNEXTHOPBUCKET
|
||||
RTM_GETNEXTHOPBUCKET,
|
||||
#define RTM_GETNEXTHOPBUCKET RTM_GETNEXTHOPBUCKET
|
||||
|
||||
__RTM_MAX,
|
||||
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
|
||||
};
|
||||
|
|
@ -264,12 +257,12 @@ enum {
|
|||
|
||||
/* rtm_protocol */
|
||||
|
||||
#define RTPROT_UNSPEC 0
|
||||
#define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
|
||||
not used by current IPv4 */
|
||||
#define RTPROT_KERNEL 2 /* Route installed by kernel */
|
||||
#define RTPROT_BOOT 3 /* Route installed during boot */
|
||||
#define RTPROT_STATIC 4 /* Route installed by administrator */
|
||||
#define RTPROT_UNSPEC 0
|
||||
#define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
|
||||
not used by current IPv4 */
|
||||
#define RTPROT_KERNEL 2 /* Route installed by kernel */
|
||||
#define RTPROT_BOOT 3 /* Route installed during boot */
|
||||
#define RTPROT_STATIC 4 /* Route installed by administrator */
|
||||
|
||||
/* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
|
||||
they are just passed from user and back as is.
|
||||
|
|
@ -278,24 +271,22 @@ enum {
|
|||
avoid conflicts.
|
||||
*/
|
||||
|
||||
#define RTPROT_GATED 8 /* Apparently, GateD */
|
||||
#define RTPROT_RA 9 /* RDISC/ND router advertisements */
|
||||
#define RTPROT_MRT 10 /* Merit MRT */
|
||||
#define RTPROT_ZEBRA 11 /* Zebra */
|
||||
#define RTPROT_BIRD 12 /* BIRD */
|
||||
#define RTPROT_DNROUTED 13 /* DECnet routing daemon */
|
||||
#define RTPROT_XORP 14 /* XORP */
|
||||
#define RTPROT_NTK 15 /* Netsukuku */
|
||||
#define RTPROT_DHCP 16 /* DHCP client */
|
||||
#define RTPROT_MROUTED 17 /* Multicast daemon */
|
||||
#define RTPROT_KEEPALIVED 18 /* Keepalived daemon */
|
||||
#define RTPROT_BABEL 42 /* Babel daemon */
|
||||
#define RTPROT_OPENR 99 /* Open Routing (Open/R) Routes */
|
||||
#define RTPROT_BGP 186 /* BGP Routes */
|
||||
#define RTPROT_ISIS 187 /* ISIS Routes */
|
||||
#define RTPROT_OSPF 188 /* OSPF Routes */
|
||||
#define RTPROT_RIP 189 /* RIP Routes */
|
||||
#define RTPROT_EIGRP 192 /* EIGRP Routes */
|
||||
#define RTPROT_GATED 8 /* Apparently, GateD */
|
||||
#define RTPROT_RA 9 /* RDISC/ND router advertisements */
|
||||
#define RTPROT_MRT 10 /* Merit MRT */
|
||||
#define RTPROT_ZEBRA 11 /* Zebra */
|
||||
#define RTPROT_BIRD 12 /* BIRD */
|
||||
#define RTPROT_DNROUTED 13 /* DECnet routing daemon */
|
||||
#define RTPROT_XORP 14 /* XORP */
|
||||
#define RTPROT_NTK 15 /* Netsukuku */
|
||||
#define RTPROT_DHCP 16 /* DHCP client */
|
||||
#define RTPROT_MROUTED 17 /* Multicast daemon */
|
||||
#define RTPROT_BABEL 42 /* Babel daemon */
|
||||
#define RTPROT_BGP 186 /* BGP Routes */
|
||||
#define RTPROT_ISIS 187 /* ISIS Routes */
|
||||
#define RTPROT_OSPF 188 /* OSPF Routes */
|
||||
#define RTPROT_RIP 189 /* RIP Routes */
|
||||
#define RTPROT_EIGRP 192 /* EIGRP Routes */
|
||||
|
||||
/* rtm_scope
|
||||
|
||||
|
|
@ -327,11 +318,6 @@ enum rt_scope_t {
|
|||
#define RTM_F_FIB_MATCH 0x2000 /* return full fib lookup match */
|
||||
#define RTM_F_OFFLOAD 0x4000 /* route is offloaded */
|
||||
#define RTM_F_TRAP 0x8000 /* route is trapping packets */
|
||||
#define RTM_F_OFFLOAD_FAILED 0x20000000 /* route offload failed, this value
|
||||
* is chosen to avoid conflicts with
|
||||
* other flags defined in
|
||||
* include/uapi/linux/ipv6_route.h
|
||||
*/
|
||||
|
||||
/* Reserved table identifiers */
|
||||
|
||||
|
|
@ -409,13 +395,11 @@ struct rtnexthop {
|
|||
#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
|
||||
#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
|
||||
#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
|
||||
#define RTNH_F_OFFLOAD 8 /* Nexthop is offloaded */
|
||||
#define RTNH_F_OFFLOAD 8 /* offloaded route */
|
||||
#define RTNH_F_LINKDOWN 16 /* carrier-down on nexthop */
|
||||
#define RTNH_F_UNRESOLVED 32 /* The entry is unresolved (ipmr) */
|
||||
#define RTNH_F_TRAP 64 /* Nexthop is trapping packets */
|
||||
|
||||
#define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | \
|
||||
RTNH_F_OFFLOAD | RTNH_F_TRAP)
|
||||
#define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD)
|
||||
|
||||
/* Macros to handle hexthops */
|
||||
|
||||
|
|
@ -625,17 +609,11 @@ enum {
|
|||
TCA_HW_OFFLOAD,
|
||||
TCA_INGRESS_BLOCK,
|
||||
TCA_EGRESS_BLOCK,
|
||||
TCA_DUMP_FLAGS,
|
||||
__TCA_MAX
|
||||
};
|
||||
|
||||
#define TCA_MAX (__TCA_MAX - 1)
|
||||
|
||||
#define TCA_DUMP_FLAGS_TERSE (1 << 0) /* Means that in dump user gets only basic
|
||||
* data necessary to identify the objects
|
||||
* (handle, cookie, etc.) and stats.
|
||||
*/
|
||||
|
||||
#define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
|
||||
#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
|
||||
|
||||
|
|
@ -779,27 +757,18 @@ enum {
|
|||
#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
|
||||
/* tcamsg flags stored in attribute TCA_ROOT_FLAGS
|
||||
*
|
||||
* TCA_ACT_FLAG_LARGE_DUMP_ON user->kernel to request for larger than
|
||||
* TCA_ACT_MAX_PRIO actions in a dump. All dump responses will contain the
|
||||
* number of actions being dumped stored in for user app's consumption in
|
||||
* TCA_ROOT_COUNT
|
||||
*
|
||||
* TCA_ACT_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only
|
||||
* includes essential action info (kind, index, etc.)
|
||||
* TCA_FLAG_LARGE_DUMP_ON user->kernel to request for larger than TCA_ACT_MAX_PRIO
|
||||
* actions in a dump. All dump responses will contain the number of actions
|
||||
* being dumped stored in for user app's consumption in TCA_ROOT_COUNT
|
||||
*
|
||||
*/
|
||||
#define TCA_FLAG_LARGE_DUMP_ON (1 << 0)
|
||||
#define TCA_ACT_FLAG_LARGE_DUMP_ON TCA_FLAG_LARGE_DUMP_ON
|
||||
#define TCA_ACT_FLAG_TERSE_DUMP (1 << 1)
|
||||
|
||||
/* New extended info filters for IFLA_EXT_MASK */
|
||||
#define RTEXT_FILTER_VF (1 << 0)
|
||||
#define RTEXT_FILTER_BRVLAN (1 << 1)
|
||||
#define RTEXT_FILTER_BRVLAN_COMPRESSED (1 << 2)
|
||||
#define RTEXT_FILTER_SKIP_STATS (1 << 3)
|
||||
#define RTEXT_FILTER_MRP (1 << 4)
|
||||
#define RTEXT_FILTER_CFM_CONFIG (1 << 5)
|
||||
#define RTEXT_FILTER_CFM_STATUS (1 << 6)
|
||||
|
||||
/* End of information exported to user level */
|
||||
|
||||
|
|
|
|||
|
|
@ -140,8 +140,6 @@ typedef __s32 sctp_assoc_t;
|
|||
#define SCTP_ECN_SUPPORTED 130
|
||||
#define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE 131
|
||||
#define SCTP_EXPOSE_PF_STATE SCTP_EXPOSE_POTENTIALLY_FAILED_STATE
|
||||
#define SCTP_REMOTE_UDP_ENCAPS_PORT 132
|
||||
#define SCTP_PLPMTUD_PROBE_INTERVAL 133
|
||||
|
||||
/* PR-SCTP policies */
|
||||
#define SCTP_PR_SCTP_NONE 0x0000
|
||||
|
|
@ -1193,12 +1191,6 @@ struct sctp_event {
|
|||
uint8_t se_on;
|
||||
};
|
||||
|
||||
struct sctp_udpencaps {
|
||||
sctp_assoc_t sue_assoc_id;
|
||||
struct sockaddr_storage sue_address;
|
||||
uint16_t sue_port;
|
||||
};
|
||||
|
||||
/* SCTP Stream schedulers */
|
||||
enum sctp_sched_type {
|
||||
SCTP_SS_FCFS,
|
||||
|
|
@ -1208,11 +1200,4 @@ enum sctp_sched_type {
|
|||
SCTP_SS_MAX = SCTP_SS_RR
|
||||
};
|
||||
|
||||
/* Probe Interval socket option */
|
||||
struct sctp_probeinterval {
|
||||
sctp_assoc_t spi_assoc_id;
|
||||
struct sockaddr_storage spi_address;
|
||||
__u32 spi_interval;
|
||||
};
|
||||
|
||||
#endif /* _SCTP_H */
|
||||
|
|
|
|||
|
|
@ -37,4 +37,5 @@ enum {
|
|||
SEG6_IPTUN_MODE_L2ENCAP,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ enum {
|
|||
SEG6_LOCAL_IIF,
|
||||
SEG6_LOCAL_OIF,
|
||||
SEG6_LOCAL_BPF,
|
||||
SEG6_LOCAL_VRFTABLE,
|
||||
SEG6_LOCAL_COUNTERS,
|
||||
__SEG6_LOCAL_MAX,
|
||||
};
|
||||
#define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1)
|
||||
|
|
@ -64,8 +62,6 @@ enum {
|
|||
SEG6_LOCAL_ACTION_END_AM = 14,
|
||||
/* custom BPF action */
|
||||
SEG6_LOCAL_ACTION_END_BPF = 15,
|
||||
/* decap and lookup of DA in v4 or v6 table */
|
||||
SEG6_LOCAL_ACTION_END_DT46 = 16,
|
||||
|
||||
__SEG6_LOCAL_ACTION_MAX,
|
||||
};
|
||||
|
|
@ -81,33 +77,4 @@ enum {
|
|||
|
||||
#define SEG6_LOCAL_BPF_PROG_MAX (__SEG6_LOCAL_BPF_PROG_MAX - 1)
|
||||
|
||||
/* SRv6 Behavior counters are encoded as netlink attributes guaranteeing the
|
||||
* correct alignment.
|
||||
* Each counter is identified by a different attribute type (i.e.
|
||||
* SEG6_LOCAL_CNT_PACKETS).
|
||||
*
|
||||
* - SEG6_LOCAL_CNT_PACKETS: identifies a counter that counts the number of
|
||||
* packets that have been CORRECTLY processed by an SRv6 Behavior instance
|
||||
* (i.e., packets that generate errors or are dropped are NOT counted).
|
||||
*
|
||||
* - SEG6_LOCAL_CNT_BYTES: identifies a counter that counts the total amount
|
||||
* of traffic in bytes of all packets that have been CORRECTLY processed by
|
||||
* an SRv6 Behavior instance (i.e., packets that generate errors or are
|
||||
* dropped are NOT counted).
|
||||
*
|
||||
* - SEG6_LOCAL_CNT_ERRORS: identifies a counter that counts the number of
|
||||
* packets that have NOT been properly processed by an SRv6 Behavior instance
|
||||
* (i.e., packets that generate errors or are dropped).
|
||||
*/
|
||||
enum {
|
||||
SEG6_LOCAL_CNT_UNSPEC,
|
||||
SEG6_LOCAL_CNT_PAD, /* pad for 64 bits values */
|
||||
SEG6_LOCAL_CNT_PACKETS,
|
||||
SEG6_LOCAL_CNT_BYTES,
|
||||
SEG6_LOCAL_CNT_ERRORS,
|
||||
__SEG6_LOCAL_CNT_MAX,
|
||||
};
|
||||
|
||||
#define SEG6_LOCAL_CNT_MAX (__SEG6_LOCAL_CNT_MAX - 1)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ enum
|
|||
UDP_MIB_SNDBUFERRORS, /* SndbufErrors */
|
||||
UDP_MIB_CSUMERRORS, /* InCsumErrors */
|
||||
UDP_MIB_IGNOREDMULTI, /* IgnoredMulti */
|
||||
UDP_MIB_MEMERRORS, /* MemErrors */
|
||||
__UDP_MIB_MAX
|
||||
};
|
||||
|
||||
|
|
@ -288,10 +287,6 @@ enum
|
|||
LINUX_MIB_TCPFASTOPENPASSIVEALTKEY, /* TCPFastOpenPassiveAltKey */
|
||||
LINUX_MIB_TCPTIMEOUTREHASH, /* TCPTimeoutRehash */
|
||||
LINUX_MIB_TCPDUPLICATEDATAREHASH, /* TCPDuplicateDataRehash */
|
||||
LINUX_MIB_TCPDSACKRECVSEGS, /* TCPDSACKRecvSegs */
|
||||
LINUX_MIB_TCPDSACKIGNOREDDUBIOUS, /* TCPDSACKIgnoredDubious */
|
||||
LINUX_MIB_TCPMIGRATEREQSUCCESS, /* TCPMigrateReqSuccess */
|
||||
LINUX_MIB_TCPMIGRATEREQFAILURE, /* TCPMigrateReqFailure */
|
||||
__LINUX_MIB_MAX
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,4 @@ struct __kernel_sockaddr_storage {
|
|||
};
|
||||
};
|
||||
|
||||
#define SOCK_SNDBUF_LOCK 1
|
||||
#define SOCK_RCVBUF_LOCK 2
|
||||
|
||||
#define SOCK_BUF_LOCK_MASK (SOCK_SNDBUF_LOCK | SOCK_RCVBUF_LOCK)
|
||||
|
||||
#endif /* _LINUX_SOCKET_H */
|
||||
|
|
|
|||
|
|
@ -4,40 +4,3 @@
|
|||
#ifndef __always_inline
|
||||
#define __always_inline __inline__
|
||||
#endif
|
||||
|
||||
/**
|
||||
* __struct_group() - Create a mirrored named and anonyomous struct
|
||||
*
|
||||
* @TAG: The tag name for the named sub-struct (usually empty)
|
||||
* @NAME: The identifier name of the mirrored sub-struct
|
||||
* @ATTRS: Any struct attributes (usually empty)
|
||||
* @MEMBERS: The member declarations for the mirrored structs
|
||||
*
|
||||
* Used to create an anonymous union of two structs with identical layout
|
||||
* and size: one anonymous and one named. The former's members can be used
|
||||
* normally without sub-struct naming, and the latter can be used to
|
||||
* reason about the start, end, and size of the group of struct members.
|
||||
* The named struct can also be explicitly tagged for layer reuse, as well
|
||||
* as both having struct attributes appended.
|
||||
*/
|
||||
#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
|
||||
union { \
|
||||
struct { MEMBERS } ATTRS; \
|
||||
struct TAG { MEMBERS } ATTRS NAME; \
|
||||
}
|
||||
|
||||
/**
|
||||
* __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
|
||||
*
|
||||
* @TYPE: The type of each flexible array element
|
||||
* @NAME: The name of the flexible array member
|
||||
*
|
||||
* In order to have a flexible array member in a union or alone in a
|
||||
* struct, it needs to be wrapped in an anonymous struct with at least 1
|
||||
* named member, but that member can be empty.
|
||||
*/
|
||||
#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
|
||||
struct { \
|
||||
struct { } __empty_ ## NAME; \
|
||||
TYPE NAME[]; \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
||||
/* Copyright 2020 NXP */
|
||||
|
||||
#ifndef __LINUX_TC_GATE_H
|
||||
#define __LINUX_TC_GATE_H
|
||||
|
||||
#include <linux/pkt_cls.h>
|
||||
|
||||
struct tc_gate {
|
||||
tc_gen;
|
||||
};
|
||||
|
||||
enum {
|
||||
TCA_GATE_ENTRY_UNSPEC,
|
||||
TCA_GATE_ENTRY_INDEX,
|
||||
TCA_GATE_ENTRY_GATE,
|
||||
TCA_GATE_ENTRY_INTERVAL,
|
||||
TCA_GATE_ENTRY_IPV,
|
||||
TCA_GATE_ENTRY_MAX_OCTETS,
|
||||
__TCA_GATE_ENTRY_MAX,
|
||||
};
|
||||
#define TCA_GATE_ENTRY_MAX (__TCA_GATE_ENTRY_MAX - 1)
|
||||
|
||||
enum {
|
||||
TCA_GATE_ONE_ENTRY_UNSPEC,
|
||||
TCA_GATE_ONE_ENTRY,
|
||||
__TCA_GATE_ONE_ENTRY_MAX,
|
||||
};
|
||||
#define TCA_GATE_ONE_ENTRY_MAX (__TCA_GATE_ONE_ENTRY_MAX - 1)
|
||||
|
||||
enum {
|
||||
TCA_GATE_UNSPEC,
|
||||
TCA_GATE_TM,
|
||||
TCA_GATE_PARMS,
|
||||
TCA_GATE_PAD,
|
||||
TCA_GATE_PRIORITY,
|
||||
TCA_GATE_ENTRY_LIST,
|
||||
TCA_GATE_BASE_TIME,
|
||||
TCA_GATE_CYCLE_TIME,
|
||||
TCA_GATE_CYCLE_TIME_EXT,
|
||||
TCA_GATE_FLAGS,
|
||||
TCA_GATE_CLOCKID,
|
||||
__TCA_GATE_MAX,
|
||||
};
|
||||
#define TCA_GATE_MAX (__TCA_GATE_MAX - 1)
|
||||
|
||||
#endif
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
#define TCA_MPLS_ACT_PUSH 2
|
||||
#define TCA_MPLS_ACT_MODIFY 3
|
||||
#define TCA_MPLS_ACT_DEC_TTL 4
|
||||
#define TCA_MPLS_ACT_MAC_PUSH 5
|
||||
|
||||
struct tc_mpls {
|
||||
tc_gen; /* generic TC action fields. */
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#define SKBMOD_F_SMAC 0x2
|
||||
#define SKBMOD_F_ETYPE 0x4
|
||||
#define SKBMOD_F_SWAPMAC 0x8
|
||||
#define SKBMOD_F_ECN 0x10
|
||||
|
||||
struct tc_skbmod {
|
||||
tc_gen;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue