Compare commits

..

No commits in common. "main" and "v5.12.0" have entirely different histories.

198 changed files with 1855 additions and 9205 deletions

View File

@ -1,8 +1,6 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Top level Makefile for iproute2 # Top level Makefile for iproute2
-include config.mk
ifeq ("$(origin V)", "command line") ifeq ("$(origin V)", "command line")
VERBOSE = $(V) VERBOSE = $(V)
endif endif
@ -15,6 +13,7 @@ MAKEFLAGS += --no-print-directory
endif endif
PREFIX?=/usr PREFIX?=/usr
LIBDIR?=$(PREFIX)/lib
SBINDIR?=/sbin SBINDIR?=/sbin
CONFDIR?=/etc/iproute2 CONFDIR?=/etc/iproute2
NETNS_RUN_DIR?=/var/run/netns NETNS_RUN_DIR?=/var/run/netns
@ -41,18 +40,9 @@ DEFINES+=-DCONFDIR=\"$(CONFDIR)\" \
-DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \ -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \
-DNETNS_ETC_DIR=\"$(NETNS_ETC_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 #options for mpls
ADDLIB+=mpls_ntop.o mpls_pton.o ADDLIB+=mpls_ntop.o mpls_pton.o
#options for NETROM
ADDLIB+=netrom_ntop.o
CC := gcc CC := gcc
HOSTCC ?= $(CC) HOSTCC ?= $(CC)
DEFINES += -D_GNU_SOURCE DEFINES += -D_GNU_SOURCE
@ -91,9 +81,7 @@ help:
@echo " V=[0|1] - set build verbosity level" @echo " V=[0|1] - set build verbosity level"
config.mk: config.mk:
@if [ ! -f config.mk -o configure -nt config.mk ]; then \ sh configure $(KERNEL_INCLUDE)
sh configure $(KERNEL_INCLUDE); \
fi
install: all install: all
install -m 0755 -d $(DESTDIR)$(SBINDIR) install -m 0755 -d $(DESTDIR)$(SBINDIR)

View File

@ -10,11 +10,6 @@ void print_vlan_info(struct rtattr *tb, int ifindex);
int print_linkinfo(struct nlmsghdr *n, void *arg); int print_linkinfo(struct nlmsghdr *n, void *arg);
int print_mdb_mon(struct nlmsghdr *n, void *arg); int print_mdb_mon(struct nlmsghdr *n, void *arg);
int print_fdb(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_fdb(int argc, char **argv);
int do_mdb(int argc, char **argv); int do_mdb(int argc, char **argv);

View File

@ -37,10 +37,10 @@ static void usage(void)
fprintf(stderr, fprintf(stderr,
"Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n" "Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
" bridge [ -force ] -batch filename\n" " bridge [ -force ] -batch filename\n"
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n" "where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n" " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
" -o[neline] | -t[imestamp] | -n[etns] name |\n" " -o[neline] | -t[imestamp] | -n[etns] name |\n"
" -c[ompressvlans] -color -p[retty] -j[son] }\n"); " -c[ompressvlans] -color -p[retty] -j[son] }\n");
exit(-1); exit(-1);
} }
@ -149,9 +149,9 @@ main(int argc, char **argv)
NEXT_ARG(); NEXT_ARG();
if (netns_switch(argv[1])) if (netns_switch(argv[1]))
exit(-1); exit(-1);
} else if (matches_color(opt, &color)) {
} else if (matches(opt, "-compressvlans") == 0) { } else if (matches(opt, "-compressvlans") == 0) {
++compress_vlans; ++compress_vlans;
} else if (matches_color(opt, &color)) {
} else if (matches(opt, "-force") == 0) { } else if (matches(opt, "-force") == 0) {
++force; ++force;
} else if (matches(opt, "-json") == 0) { } else if (matches(opt, "-json") == 0) {

View File

@ -192,13 +192,10 @@ int print_fdb(struct nlmsghdr *n, void *arg)
"mac", "%s ", lladdr); "mac", "%s ", lladdr);
} }
if (!filter_index && r->ndm_ifindex) { if (!filter_index && r->ndm_ifindex)
print_string(PRINT_FP, NULL, "dev ", NULL);
print_color_string(PRINT_ANY, COLOR_IFNAME, print_color_string(PRINT_ANY, COLOR_IFNAME,
"ifname", "%s ", "ifname", "dev %s ",
ll_index_to_name(r->ndm_ifindex)); ll_index_to_name(r->ndm_ifindex));
}
if (tb[NDA_DST]) { if (tb[NDA_DST]) {
int family = AF_INET; int family = AF_INET;
@ -211,11 +208,9 @@ int print_fdb(struct nlmsghdr *n, void *arg)
RTA_PAYLOAD(tb[NDA_DST]), RTA_PAYLOAD(tb[NDA_DST]),
RTA_DATA(tb[NDA_DST])); RTA_DATA(tb[NDA_DST]));
print_string(PRINT_FP, NULL, "dst ", NULL);
print_color_string(PRINT_ANY, print_color_string(PRINT_ANY,
ifa_family_color(family), ifa_family_color(family),
"dst", "%s ", dst); "dst", "dst %s ", dst);
} }
if (vid) if (vid)

View File

@ -19,7 +19,7 @@
static unsigned int filter_index; static unsigned int filter_index;
static const char *stp_states[] = { static const char *port_states[] = {
[BR_STATE_DISABLED] = "disabled", [BR_STATE_DISABLED] = "disabled",
[BR_STATE_LISTENING] = "listening", [BR_STATE_LISTENING] = "listening",
[BR_STATE_LEARNING] = "learning", [BR_STATE_LEARNING] = "learning",
@ -68,31 +68,16 @@ static void print_link_flags(FILE *fp, unsigned int flags, unsigned int mdown)
close_json_array(PRINT_ANY, "> "); close_json_array(PRINT_ANY, "> ");
} }
void print_stp_state(__u8 state) static void print_portstate(__u8 state)
{ {
if (state <= BR_STATE_BLOCKING) if (state <= BR_STATE_BLOCKING)
print_string(PRINT_ANY, "state", print_string(PRINT_ANY, "state",
"state %s ", stp_states[state]); "state %s ", port_states[state]);
else else
print_uint(PRINT_ANY, "state", print_uint(PRINT_ANY, "state",
"state (%d) ", state); "state (%d) ", state);
} }
int parse_stp_state(const char *arg)
{
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;
}
static void print_hwmode(__u16 mode) static void print_hwmode(__u16 mode)
{ {
if (mode >= ARRAY_SIZE(hw_mode)) if (mode >= ARRAY_SIZE(hw_mode))
@ -111,7 +96,7 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
parse_rtattr_nested(prtb, IFLA_BRPORT_MAX, attr); parse_rtattr_nested(prtb, IFLA_BRPORT_MAX, attr);
if (prtb[IFLA_BRPORT_STATE]) 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]) if (prtb[IFLA_BRPORT_PRIORITY])
print_uint(PRINT_ANY, "priority", print_uint(PRINT_ANY, "priority",
@ -176,7 +161,7 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
print_on_off(PRINT_ANY, "isolated", "isolated %s ", print_on_off(PRINT_ANY, "isolated", "isolated %s ",
rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED])); rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
} else } else
print_stp_state(rta_getattr_u8(attr)); print_portstate(rta_getattr_u8(attr));
} }
@ -374,11 +359,14 @@ static int brlink_modify(int argc, char **argv)
} else if (strcmp(*argv, "state") == 0) { } else if (strcmp(*argv, "state") == 0) {
NEXT_ARG(); NEXT_ARG();
char *endptr; char *endptr;
size_t nstates = ARRAY_SIZE(port_states);
state = strtol(*argv, &endptr, 10); state = strtol(*argv, &endptr, 10);
if (!(**argv != '\0' && *endptr == '\0')) { if (!(**argv != '\0' && *endptr == '\0')) {
state = parse_stp_state(*argv); for (state = 0; state < nstates; state++)
if (state == -1) { if (strcasecmp(port_states[state], *argv) == 0)
break;
if (state == nstates) {
fprintf(stderr, fprintf(stderr,
"Error: invalid STP port state\n"); "Error: invalid STP port state\n");
return -1; return -1;

View File

@ -16,9 +16,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include "libnetlink.h" #include "libnetlink.h"
#include "utils.h"
#include "br_common.h" #include "br_common.h"
#include "rt_names.h" #include "rt_names.h"
#include "utils.h"
#include "json_print.h" #include "json_print.h"
#ifndef MDBA_RTA #ifndef MDBA_RTA
@ -59,7 +59,7 @@ static const char *format_timer(__u32 ticks, int align)
return tbuf; 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]; struct rtattr *tb[MDBA_ROUTER_PATTR_MAX + 1];
@ -101,13 +101,13 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr,
print_string(PRINT_JSON, "port", NULL, port_ifname); print_string(PRINT_JSON, "port", NULL, port_ifname);
if (show_stats) if (show_stats)
br_print_router_port_stats(i); __print_router_port_stats(f, i);
close_json_object(); close_json_object();
} else if (show_stats) { } else if (show_stats) {
fprintf(f, "router ports on %s: %s", fprintf(f, "router ports on %s: %s",
brifname, port_ifname); brifname, port_ifname);
br_print_router_port_stats(i); __print_router_port_stats(f, i);
fprintf(f, "\n"); fprintf(f, "\n");
} else { } else {
fprintf(f, "%s ", port_ifname); fprintf(f, "%s ", port_ifname);

View File

@ -31,7 +31,7 @@ static int prefix_banner;
static void usage(void) 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); exit(-1);
} }
@ -67,12 +67,6 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,
print_nlmsg_timestamp(fp, n); print_nlmsg_timestamp(fp, n);
return 0; return 0;
case RTM_NEWVLAN:
case RTM_DELVLAN:
if (prefix_banner)
fprintf(fp, "[VLAN]");
return print_vlan_rtm(n, arg, true, false);
default: default:
return 0; return 0;
} }
@ -85,7 +79,6 @@ int do_monitor(int argc, char **argv)
int llink = 0; int llink = 0;
int lneigh = 0; int lneigh = 0;
int lmdb = 0; int lmdb = 0;
int lvlan = 0;
rtnl_close(&rth); rtnl_close(&rth);
@ -102,12 +95,8 @@ int do_monitor(int argc, char **argv)
} else if (matches(*argv, "mdb") == 0) { } else if (matches(*argv, "mdb") == 0) {
lmdb = 1; lmdb = 1;
groups = 0; groups = 0;
} else if (matches(*argv, "vlan") == 0) {
lvlan = 1;
groups = 0;
} else if (strcmp(*argv, "all") == 0) { } else if (strcmp(*argv, "all") == 0) {
groups = ~RTMGRP_TC; groups = ~RTMGRP_TC;
lvlan = 1;
prefix_banner = 1; prefix_banner = 1;
} else if (matches(*argv, "help") == 0) { } else if (matches(*argv, "help") == 0) {
usage(); usage();
@ -145,12 +134,6 @@ int do_monitor(int argc, char **argv)
if (rtnl_open(&rth, groups) < 0) if (rtnl_open(&rth, groups) < 0)
exit(1); 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); ll_init_map(&rth);
if (rtnl_listen(&rth, accept_msg, stdout) < 0) if (rtnl_listen(&rth, accept_msg, stdout) < 0)

View File

@ -9,7 +9,6 @@
#include <linux/if_bridge.h> #include <linux/if_bridge.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include "json_print.h" #include "json_print.h"
#include "libnetlink.h" #include "libnetlink.h"
@ -17,7 +16,6 @@
#include "utils.h" #include "utils.h"
static unsigned int filter_index, filter_vlan; static unsigned int filter_index, filter_vlan;
static int vlan_rtm_cur_ifidx = -1;
enum vlan_show_subject { enum vlan_show_subject {
VLAN_SHOW_VLAN, 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" "Usage: bridge vlan { add | del } vid VLAN_ID dev DEV [ tunnel_info id TUNNEL_ID ]\n"
" [ pvid ] [ untagged ]\n" " [ pvid ] [ untagged ]\n"
" [ self ] [ master ]\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 { show } [ dev DEV ] [ vid VLAN_ID ]\n"
" bridge vlan { tunnelshow } [ 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");
exit(-1); exit(-1);
} }
@ -259,277 +241,6 @@ static int vlan_modify(int cmd, int argc, char **argv)
return 0; 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 /* In order to use this function for both filtering and non-filtering cases
* we need to make it a tristate: * we need to make it a tristate:
* return -1 - if filtering we've gone over so don't continue * 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); 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_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s ", "");
print_lluint(PRINT_ANY, "rx_bytes", "RX: %llu bytes", print_lluint(PRINT_ANY, "rx_bytes", "RX: %llu bytes",
vstats->rx_bytes); vstats->rx_bytes);
@ -724,16 +441,6 @@ static void __print_one_vlan_stats(const struct bridge_vlan_xstats *vstats)
vstats->tx_bytes); vstats->tx_bytes);
print_lluint(PRINT_ANY, "tx_packets", " %llu packets\n", print_lluint(PRINT_ANY, "tx_packets", " %llu packets\n",
vstats->tx_packets); 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(); close_json_object();
} }
@ -814,288 +521,6 @@ static int print_vlan_stats(struct nlmsghdr *n, void *arg)
return 0; 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) static int vlan_show(int argc, char **argv, int subject)
{ {
char *filter_dev = NULL; char *filter_dev = NULL;
@ -1124,34 +549,6 @@ static int vlan_show(int argc, char **argv, int subject)
new_json_obj(json); 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 (!show_stats) {
if (rtnl_linkdump_req_filter(&rth, PF_BRIDGE, if (rtnl_linkdump_req_filter(&rth, PF_BRIDGE,
(compress_vlans ? (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(); delete_json_obj();
fflush(stdout); fflush(stdout);
return 0; return 0;
@ -1310,24 +651,6 @@ void print_vlan_info(struct rtattr *tb, int ifindex)
close_vlan_port(); 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) int do_vlan(int argc, char **argv)
{ {
ll_init_map(&rth); ll_init_map(&rth);
@ -1344,10 +667,6 @@ int do_vlan(int argc, char **argv)
if (matches(*argv, "tunnelshow") == 0) { if (matches(*argv, "tunnelshow") == 0) {
return vlan_show(argc-1, argv+1, VLAN_SHOW_TUNNELINFO); 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) if (matches(*argv, "help") == 0)
usage(); usage();
} else { } else {

117
configure vendored
View File

@ -1,10 +1,13 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# This is not an autoconf generated configure # This is not an autoconf generated configure
#
# Influential LIBBPF environment variables:
# LIBBPF_FORCE={on,off} on: require link against libbpf;
# off: disable libbpf probing
# LIBBPF_DIR Path to libbpf DESTDIR to use
INCLUDE="$PWD/include" INCLUDE=${1:-"$PWD/include"}
PREFIX="/usr"
LIBDIR="\${prefix}/lib"
# Output file which is input to Makefile # Output file which is input to Makefile
CONFIG=config.mk CONFIG=config.mk
@ -150,15 +153,6 @@ EOF
rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest 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() check_ipt()
{ {
if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then if ! grep TC_CONFIG_XT $CONFIG > /dev/null; then
@ -208,31 +202,6 @@ EOF
rm -f $TMPDIR/setnstest.c $TMPDIR/setnstest 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() check_ipset()
{ {
cat >$TMPDIR/ipsettest.c <<EOF cat >$TMPDIR/ipsettest.c <<EOF
@ -492,76 +461,6 @@ endif
EOF 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 echo "# Generated config based on" $INCLUDE >$CONFIG
quiet_config >> $CONFIG quiet_config >> $CONFIG
@ -585,7 +484,6 @@ if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
fi fi
echo echo
check_lib_dir
if ! grep -q TC_CONFIG_NO_XT $CONFIG; then if ! grep -q TC_CONFIG_NO_XT $CONFIG; then
echo -n "iptables modules directory: " echo -n "iptables modules directory: "
check_ipt_lib_dir check_ipt_lib_dir
@ -594,9 +492,6 @@ fi
echo -n "libc has setns: " echo -n "libc has setns: "
check_setns check_setns
echo -n "libc has name_to_handle_at: "
check_name_to_handle_at
echo -n "SELinux support: " echo -n "SELinux support: "
check_selinux check_selinux

View File

@ -571,8 +571,7 @@ int main(int argc, char **argv)
break; break;
case 'h': case 'h':
dcb_help(); dcb_help();
ret = EXIT_SUCCESS; return 0;
goto dcb_free;
default: default:
fprintf(stderr, "Unknown option.\n"); fprintf(stderr, "Unknown option.\n");
dcb_help(); dcb_help();

View File

@ -667,7 +667,7 @@ static int dcb_cmd_app_show(struct dcb *dcb, const char *dev, int argc, char **a
out: out:
close_json_object(); close_json_object();
dcb_app_table_fini(&tab); dcb_app_table_fini(&tab);
return ret; return 0;
} }
static int dcb_cmd_app_flush(struct dcb *dcb, const char *dev, int argc, char **argv) static int dcb_cmd_app_flush(struct dcb *dcb, const char *dev, int argc, char **argv)

View File

@ -7,7 +7,6 @@ ifeq ($(HAVE_MNL),y)
DEVLINKOBJ = devlink.o mnlg.o DEVLINKOBJ = devlink.o mnlg.o
TARGETS += devlink TARGETS += devlink
LDLIBS += -lm
endif endif

File diff suppressed because it is too large Load Diff

View File

@ -30,11 +30,38 @@ struct mnlg_socket {
unsigned int seq; unsigned int seq;
}; };
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 genlmsghdr genl = {
.cmd = cmd,
.version = version,
};
struct nlmsghdr *nlh;
nlh = mnlu_msg_prepare(nlg->buf, id, flags, &genl, sizeof(genl));
nlg->seq = nlh->nlmsg_seq;
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); return mnl_socket_sendto(nlg->nl, nlh, nlh->nlmsg_len);
} }
int mnlg_socket_recv_run(struct mnlg_socket *nlg, mnl_cb_t data_cb, void *data)
{
return mnlu_socket_recv_run(nlg->nl, nlg->seq, nlg->buf, MNL_SOCKET_BUFFER_SIZE,
data_cb, data);
}
struct group_info { struct group_info {
bool found; bool found;
uint32_t id; uint32_t id;
@ -114,17 +141,15 @@ static int get_group_id_cb(const struct nlmsghdr *nlh, void *data)
return MNL_CB_OK; 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 nlmsghdr *nlh;
struct group_info group_info; struct group_info group_info;
int err; int err;
nlh = _mnlu_gen_socket_cmd_prepare(nlg, CTRL_CMD_GETFAMILY, nlh = __mnlg_msg_prepare(nlg, CTRL_CMD_GETFAMILY,
NLM_F_REQUEST | NLM_F_ACK, NLM_F_REQUEST | NLM_F_ACK, GENL_ID_CTRL, 1);
GENL_ID_CTRL, 1); mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, nlg->id);
mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, nlg->family);
err = mnlg_socket_send(nlg, nlh); err = mnlg_socket_send(nlg, nlh);
if (err < 0) if (err < 0)
@ -132,7 +157,7 @@ int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name)
group_info.found = false; group_info.found = false;
group_info.name = group_name; 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) if (err < 0)
return err; return err;
@ -149,7 +174,85 @@ int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name)
return 0; 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 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 = mnlu_socket_open(NETLINK_GENERIC);
if (!nlg->nl)
goto err_socket_open;
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:
mnl_socket_close(nlg->nl);
err_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); return mnl_socket_get_fd(nlg->nl);
} }

View File

@ -14,10 +14,15 @@
#include <libmnl/libmnl.h> #include <libmnl/libmnl.h>
struct mnlu_gen_socket; struct mnlg_socket;
int mnlg_socket_send(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh); struct nlmsghdr *mnlg_msg_prepare(struct mnlg_socket *nlg, uint8_t cmd,
int mnlg_socket_group_add(struct mnlu_gen_socket *nlg, const char *group_name); uint16_t flags);
int mnlg_socket_get_fd(struct mnlu_gen_socket *nlg); 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_ */ #endif /* _MNLG_H_ */

View File

@ -10,7 +10,7 @@ Where:
ACTION semantics ACTION semantics
- pass and ok are equivalent to accept - pass and ok are equivalent to accept
- continue allows one to restart classification lookup - continue allows to restart classification lookup
- drop drops packets - drop drops packets
- reclassify implies continue classification where we left off - reclassify implies continue classification where we left off

View File

@ -17,7 +17,6 @@
16 dhcp 16 dhcp
18 keepalived 18 keepalived
42 babel 42 babel
99 openr
186 bgp 186 bgp
187 isis 187 isis
188 ospf 188 ospf

View File

@ -81,7 +81,6 @@ _PRINT_FUNC(0xhex, unsigned long long)
_PRINT_FUNC(luint, unsigned long) _PRINT_FUNC(luint, unsigned long)
_PRINT_FUNC(lluint, unsigned long long) _PRINT_FUNC(lluint, unsigned long long)
_PRINT_FUNC(float, double) _PRINT_FUNC(float, double)
_PRINT_FUNC(tv, const struct timeval *)
#undef _PRINT_FUNC #undef _PRINT_FUNC
#define _PRINT_NAME_VALUE_FUNC(type_name, type, format_char) \ #define _PRINT_NAME_VALUE_FUNC(type_name, type, format_char) \

View File

@ -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_resolve_family(struct rtnl_handle *grth, const char *family);
int genl_init_handle(struct rtnl_handle *grth, const char *family, int genl_init_handle(struct rtnl_handle *grth, const char *family,
int *genl_family); int *genl_family);

View File

@ -69,8 +69,6 @@ int rtnl_neightbldump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
int rtnl_mdbdump_req(struct rtnl_handle *rth, int family) int rtnl_mdbdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __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) int rtnl_netconfdump_req(struct rtnl_handle *rth, int family)
__attribute__((warn_unused_result)); __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, int rtnl_nexthopdump_req(struct rtnl_handle *rth, int family,
req_filter_fn_t filter_fn) req_filter_fn_t filter_fn)
__attribute__((warn_unused_result)); __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 { struct rtnl_ctrl_data {
int nsid; int nsid;
@ -109,27 +104,6 @@ struct rtnl_ctrl_data {
typedef int (*rtnl_filter_t)(struct nlmsghdr *n, void *); 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 *, typedef int (*rtnl_listen_filter_t)(struct rtnl_ctrl_data *,
struct nlmsghdr *n, void *); 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 { struct rtnl_dump_filter_arg {
rtnl_filter_t filter; rtnl_filter_t filter;
void *arg1; void *arg1;
rtnl_err_hndlr_t errhndlr;
void *arg2;
__u16 nc_flags; __u16 nc_flags;
}; };
@ -149,15 +121,6 @@ int rtnl_dump_filter_nc(struct rtnl_handle *rth,
void *arg, __u16 nc_flags); void *arg, __u16 nc_flags);
#define rtnl_dump_filter(rth, filter, arg) \ #define rtnl_dump_filter(rth, filter, arg) \
rtnl_dump_filter_nc(rth, filter, arg, 0) 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, int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
struct nlmsghdr **answer) struct nlmsghdr **answer)
__attribute__((warn_unused_result)); __attribute__((warn_unused_result));
@ -317,11 +280,6 @@ int rtnl_from_file(FILE *, rtnl_listen_filter_t handler,
((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct if_stats_msg)))) ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct if_stats_msg))))
#endif #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 /* User defined nlmsg_type which is used mostly for logging netlink
* messages from dump file */ * messages from dump file */
#define NLMSG_TSTAMP 15 #define NLMSG_TSTAMP 15

View File

@ -13,10 +13,6 @@ struct mnlu_gen_socket {
int mnlu_gen_socket_open(struct mnlu_gen_socket *nlg, const char *family_name, int mnlu_gen_socket_open(struct mnlu_gen_socket *nlg, const char *family_name,
uint8_t version); uint8_t version);
void mnlu_gen_socket_close(struct mnlu_gen_socket *nlg); 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, struct nlmsghdr *mnlu_gen_socket_cmd_prepare(struct mnlu_gen_socket *nlg,
uint8_t cmd, uint16_t flags); uint8_t cmd, uint16_t flags);
int mnlu_gen_socket_sndrcv(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh, int mnlu_gen_socket_sndrcv(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh,
@ -27,7 +23,5 @@ struct nlmsghdr *mnlu_msg_prepare(void *buf, uint32_t nlmsg_type, uint16_t flags
void *extra_header, size_t extra_header_size); 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, int mnlu_socket_recv_run(struct mnl_socket *nl, unsigned int seq, void *buf, size_t buf_size,
mnl_cb_t cb, void *data); 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__ */ #endif /* __MNL_UTILS_H__ */

View File

@ -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_ */

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@ struct btf_type {
* "size" tells the size of the type it is describing. * "size" tells the size of the type it is describing.
* *
* "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT, * "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. * "type" is a type_id referring to another type.
*/ */
union { 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_VLEN(info) ((info) & 0xffff)
#define BTF_INFO_KFLAG(info) ((info) >> 31) #define BTF_INFO_KFLAG(info) ((info) >> 31)
enum { #define BTF_KIND_UNKN 0 /* Unknown */
BTF_KIND_UNKN = 0, /* Unknown */ #define BTF_KIND_INT 1 /* Integer */
BTF_KIND_INT = 1, /* Integer */ #define BTF_KIND_PTR 2 /* Pointer */
BTF_KIND_PTR = 2, /* Pointer */ #define BTF_KIND_ARRAY 3 /* Array */
BTF_KIND_ARRAY = 3, /* Array */ #define BTF_KIND_STRUCT 4 /* Struct */
BTF_KIND_STRUCT = 4, /* Struct */ #define BTF_KIND_UNION 5 /* Union */
BTF_KIND_UNION = 5, /* Union */ #define BTF_KIND_ENUM 6 /* Enumeration */
BTF_KIND_ENUM = 6, /* Enumeration */ #define BTF_KIND_FWD 7 /* Forward */
BTF_KIND_FWD = 7, /* Forward */ #define BTF_KIND_TYPEDEF 8 /* Typedef */
BTF_KIND_TYPEDEF = 8, /* Typedef */ #define BTF_KIND_VOLATILE 9 /* Volatile */
BTF_KIND_VOLATILE = 9, /* Volatile */ #define BTF_KIND_CONST 10 /* Const */
BTF_KIND_CONST = 10, /* Const */ #define BTF_KIND_RESTRICT 11 /* Restrict */
BTF_KIND_RESTRICT = 11, /* Restrict */ #define BTF_KIND_FUNC 12 /* Function */
BTF_KIND_FUNC = 12, /* Function */ #define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
BTF_KIND_FUNC_PROTO = 13, /* Function Proto */ #define BTF_KIND_VAR 14 /* Variable */
BTF_KIND_VAR = 14, /* Variable */ #define BTF_KIND_DATASEC 15 /* Section */
BTF_KIND_DATASEC = 15, /* Section */ #define BTF_KIND_MAX BTF_KIND_DATASEC
BTF_KIND_FLOAT = 16, /* Floating point */ #define NR_BTF_KINDS (BTF_KIND_MAX + 1)
BTF_KIND_DECL_TAG = 17, /* Decl Tag */
NR_BTF_KINDS,
BTF_KIND_MAX = NR_BTF_KINDS - 1,
};
/* For some specific BTF_KIND, "struct btf_type" is immediately /* For some specific BTF_KIND, "struct btf_type" is immediately
* followed by extra data. * followed by extra data.
@ -174,15 +169,4 @@ struct btf_var_secinfo {
__u32 size; __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__ */ #endif /* __LINUX_BTF_H__ */

View File

@ -123,8 +123,8 @@ struct can_frame {
/* /*
* defined bits for canfd_frame.flags * defined bits for canfd_frame.flags
* *
* The use of struct canfd_frame implies the FD Frame (FDF) bit to * 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 FDF bit switch turns * 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 * the CAN controllers bitstream processor into the CAN FD mode which creates
* two new options within the CAN FD frame specification: * two new options within the CAN FD frame specification:
* *
@ -135,18 +135,9 @@ struct can_frame {
* controller only the CANFD_BRS bit is relevant for real CAN controllers when * 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 * 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. * 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_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */ #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 * struct canfd_frame - CAN flexible data rate frame structure

View File

@ -101,8 +101,6 @@ struct can_ctrlmode {
#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */ #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_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
#define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */ #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 * CAN device statistics
@ -136,35 +134,10 @@ enum {
IFLA_CAN_BITRATE_CONST, IFLA_CAN_BITRATE_CONST,
IFLA_CAN_DATA_BITRATE_CONST, IFLA_CAN_DATA_BITRATE_CONST,
IFLA_CAN_BITRATE_MAX, IFLA_CAN_BITRATE_MAX,
IFLA_CAN_TDC, __IFLA_CAN_MAX
/* add new constants above here */
__IFLA_CAN_MAX,
IFLA_CAN_MAX = __IFLA_CAN_MAX - 1
}; };
/* #define IFLA_CAN_MAX (__IFLA_CAN_MAX - 1)
* 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
};
/* u16 termination range: 1..65535 Ohms */ /* u16 termination range: 1..65535 Ohms */
#define CAN_TERMINATION_DISABLED 0 #define CAN_TERMINATION_DISABLED 0

View File

@ -126,11 +126,6 @@ enum devlink_command {
DEVLINK_CMD_HEALTH_REPORTER_TEST, 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 */ /* add new commands above here */
__DEVLINK_CMD_MAX, __DEVLINK_CMD_MAX,
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
@ -211,11 +206,6 @@ enum devlink_port_flavour {
*/ */
}; };
enum devlink_rate_type {
DEVLINK_RATE_TYPE_LEAF,
DEVLINK_RATE_TYPE_NODE,
};
enum devlink_param_cmode { enum devlink_param_cmode {
DEVLINK_PARAM_CMODE_RUNTIME, DEVLINK_PARAM_CMODE_RUNTIME,
DEVLINK_PARAM_CMODE_DRIVERINIT, DEVLINK_PARAM_CMODE_DRIVERINIT,
@ -544,15 +534,6 @@ enum devlink_attr {
DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */ DEVLINK_ATTR_RELOAD_ACTION_STATS, /* nested */
DEVLINK_ATTR_PORT_PCI_SF_NUMBER, /* u32 */ 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 */ /* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX, __DEVLINK_ATTR_MAX,

View File

@ -140,9 +140,6 @@ struct icmp6hdr {
#define ICMPV6_UNK_OPTION 2 #define ICMPV6_UNK_OPTION 2
#define ICMPV6_HDR_INCOMP 3 #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 * constants for (set|get)sockopt
*/ */

View File

@ -54,7 +54,6 @@
#define ARPHRD_X25 271 /* CCITT X.25 */ #define ARPHRD_X25 271 /* CCITT X.25 */
#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */ #define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */
#define ARPHRD_CAN 280 /* Controller Area Network */ #define ARPHRD_CAN 280 /* Controller Area Network */
#define ARPHRD_MCTP 290
#define ARPHRD_PPP 512 #define ARPHRD_PPP 512
#define ARPHRD_CISCO 513 /* Cisco HDLC */ #define ARPHRD_CISCO 513 /* Cisco HDLC */
#define ARPHRD_HDLC ARPHRD_CISCO #define ARPHRD_HDLC ARPHRD_CISCO

View File

@ -153,3 +153,14 @@ enum {
#define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1) #define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
#endif /* _LINUX_IF_BONDING_H */ #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:
*/

View File

@ -479,22 +479,16 @@ enum {
/* flags used in BRIDGE_VLANDB_DUMP_FLAGS attribute to affect dumps */ /* 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_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 vlan RTM attributes
* [BRIDGE_VLANDB_ENTRY] = { * [BRIDGE_VLANDB_ENTRY] = {
* [BRIDGE_VLANDB_ENTRY_INFO] * [BRIDGE_VLANDB_ENTRY_INFO]
* ... * ...
* } * }
* [BRIDGE_VLANDB_GLOBAL_OPTIONS] = {
* [BRIDGE_VLANDB_GOPTS_ID]
* ...
* }
*/ */
enum { enum {
BRIDGE_VLANDB_UNSPEC, BRIDGE_VLANDB_UNSPEC,
BRIDGE_VLANDB_ENTRY, BRIDGE_VLANDB_ENTRY,
BRIDGE_VLANDB_GLOBAL_OPTIONS,
__BRIDGE_VLANDB_MAX, __BRIDGE_VLANDB_MAX,
}; };
#define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1) #define BRIDGE_VLANDB_MAX (__BRIDGE_VLANDB_MAX - 1)
@ -506,7 +500,6 @@ enum {
BRIDGE_VLANDB_ENTRY_STATE, BRIDGE_VLANDB_ENTRY_STATE,
BRIDGE_VLANDB_ENTRY_TUNNEL_INFO, BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,
BRIDGE_VLANDB_ENTRY_STATS, BRIDGE_VLANDB_ENTRY_STATS,
BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
__BRIDGE_VLANDB_ENTRY_MAX, __BRIDGE_VLANDB_ENTRY_MAX,
}; };
#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1) #define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
@ -545,29 +538,6 @@ enum {
}; };
#define BRIDGE_VLANDB_STATS_MAX (__BRIDGE_VLANDB_STATS_MAX - 1) #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 /* Bridge multicast database attributes
* [MDBA_MDB] = { * [MDBA_MDB] = {
* [MDBA_MDB_ENTRY] = { * [MDBA_MDB_ENTRY] = {
@ -657,9 +627,6 @@ enum {
MDBA_ROUTER_PATTR_UNSPEC, MDBA_ROUTER_PATTR_UNSPEC,
MDBA_ROUTER_PATTR_TIMER, MDBA_ROUTER_PATTR_TIMER,
MDBA_ROUTER_PATTR_TYPE, MDBA_ROUTER_PATTR_TYPE,
MDBA_ROUTER_PATTR_INET_TIMER,
MDBA_ROUTER_PATTR_INET6_TIMER,
MDBA_ROUTER_PATTR_VID,
__MDBA_ROUTER_PATTR_MAX __MDBA_ROUTER_PATTR_MAX
}; };
#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1) #define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
@ -751,14 +718,12 @@ struct br_mcast_stats {
/* bridge boolean options /* bridge boolean options
* BR_BOOLOPT_NO_LL_LEARN - disable learning from link-local packets * 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 * IMPORTANT: if adding a new option do not forget to handle
* it in br_boolopt_toggle/get and bridge sysfs * it in br_boolopt_toggle/get and bridge sysfs
*/ */
enum br_boolopt_id { enum br_boolopt_id {
BR_BOOLOPT_NO_LL_LEARN, BR_BOOLOPT_NO_LL_LEARN,
BR_BOOLOPT_MCAST_VLAN_SNOOPING,
BR_BOOLOPT_MAX BR_BOOLOPT_MAX
}; };
@ -771,17 +736,4 @@ struct br_boolopt_multi {
__u32 optval; __u32 optval;
__u32 optmask; __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 */ #endif /* _LINUX_IF_BRIDGE_H */

View File

@ -86,7 +86,6 @@
* over Ethernet * over Ethernet
*/ */
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ #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_AOE 0x88A2 /* ATA over Ethernet */
#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */ #define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */
#define ETH_P_802_EX1 0x88B5 /* 802.1 Local Experimental 1. */ #define ETH_P_802_EX1 0x88B5 /* 802.1 Local Experimental 1. */
@ -117,7 +116,7 @@
#define ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */ #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_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 */ * then the frame is Ethernet II. Else it is 802.3 */
/* /*
@ -152,9 +151,6 @@
#define ETH_P_MAP 0x00F9 /* Qualcomm multiplexing and #define ETH_P_MAP 0x00F9 /* Qualcomm multiplexing and
* aggregation protocol * aggregation protocol
*/ */
#define ETH_P_MCTP 0x00FA /* Management component transport
* protocol packets
*/
/* /*
* This is an Ethernet frame header. * This is an Ethernet frame header.

View File

@ -341,13 +341,6 @@ enum {
IFLA_ALT_IFNAME, /* Alternative ifname */ IFLA_ALT_IFNAME, /* Alternative ifname */
IFLA_PERM_ADDRESS, IFLA_PERM_ADDRESS,
IFLA_PROTO_DOWN_REASON, 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 __IFLA_MAX
}; };
@ -415,7 +408,6 @@ enum {
IFLA_INET6_ICMP6STATS, /* statistics (icmpv6) */ IFLA_INET6_ICMP6STATS, /* statistics (icmpv6) */
IFLA_INET6_TOKEN, /* device token */ IFLA_INET6_TOKEN, /* device token */
IFLA_INET6_ADDR_GEN_MODE, /* implicit address generator mode */ IFLA_INET6_ADDR_GEN_MODE, /* implicit address generator mode */
IFLA_INET6_RA_MTU, /* mtu carried in the RA message */
__IFLA_INET6_MAX __IFLA_INET6_MAX
}; };
@ -478,7 +470,6 @@ enum {
IFLA_BR_MCAST_MLD_VERSION, IFLA_BR_MCAST_MLD_VERSION,
IFLA_BR_VLAN_STATS_PER_PORT, IFLA_BR_VLAN_STATS_PER_PORT,
IFLA_BR_MULTI_BOOLOPT, IFLA_BR_MULTI_BOOLOPT,
IFLA_BR_MCAST_QUERIER_STATE,
__IFLA_BR_MAX, __IFLA_BR_MAX,
}; };
@ -621,7 +612,6 @@ enum macvlan_macaddr_mode {
}; };
#define MACVLAN_FLAG_NOPROMISC 1 #define MACVLAN_FLAG_NOPROMISC 1
#define MACVLAN_FLAG_NODST 2 /* skip dst macvlan if matching src macvlan */
/* VRF section */ /* VRF section */
enum { enum {
@ -855,7 +845,6 @@ enum {
IFLA_BOND_AD_ACTOR_SYSTEM, IFLA_BOND_AD_ACTOR_SYSTEM,
IFLA_BOND_TLB_DYNAMIC_LB, IFLA_BOND_TLB_DYNAMIC_LB,
IFLA_BOND_PEER_NOTIF_DELAY, IFLA_BOND_PEER_NOTIF_DELAY,
IFLA_BOND_AD_LACP_ACTIVE,
__IFLA_BOND_MAX, __IFLA_BOND_MAX,
}; };
@ -1244,8 +1233,6 @@ enum {
#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) #define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1)
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) #define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2)
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) #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 { enum {
IFLA_RMNET_UNSPEC, IFLA_RMNET_UNSPEC,
@ -1261,14 +1248,4 @@ struct ifla_rmnet_flags {
__u32 mask; __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 */ #endif /* _LINUX_IF_LINK_H */

View File

@ -188,22 +188,11 @@ struct ip_mreq_source {
}; };
struct ip_msfilter { struct ip_msfilter {
union { __be32 imsf_multiaddr;
struct { __be32 imsf_interface;
__be32 imsf_multiaddr_aux; __u32 imsf_fmode;
__be32 imsf_interface_aux; __u32 imsf_numsrc;
__u32 imsf_fmode_aux; __be32 imsf_slist[1];
__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[];
};
};
}; };
#define IP_MSFILTER_SIZE(numsrc) \ #define IP_MSFILTER_SIZE(numsrc) \
@ -222,22 +211,11 @@ struct group_source_req {
}; };
struct group_filter { struct group_filter {
union { __u32 gf_interface; /* interface index */
struct { struct __kernel_sockaddr_storage gf_group; /* multicast address */
__u32 gf_interface_aux; /* interface index */ __u32 gf_fmode; /* filter mode */
struct __kernel_sockaddr_storage gf_group_aux; /* multicast address */ __u32 gf_numsrc; /* number of sources */
__u32 gf_fmode_aux; /* filter mode */ struct __kernel_sockaddr_storage gf_slist[1]; /* interface index */
__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 */
};
};
}; };
#define GROUP_FILTER_SIZE(numsrc) \ #define GROUP_FILTER_SIZE(numsrc) \
@ -311,9 +289,6 @@ struct sockaddr_in {
/* Address indicating an error return. */ /* Address indicating an error return. */
#define INADDR_NONE ((unsigned long int) 0xffffffff) #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. */ /* Network number for local host loopback. */
#define IN_LOOPBACKNET 127 #define IN_LOOPBACKNET 127

View File

@ -145,7 +145,6 @@ struct in6_flowlabel_req {
#define IPV6_TLV_PADN 1 #define IPV6_TLV_PADN 1
#define IPV6_TLV_ROUTERALERT 5 #define IPV6_TLV_ROUTERALERT 5
#define IPV6_TLV_CALIPSO 7 /* RFC 5570 */ #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_JUMBO 194
#define IPV6_TLV_HAO 201 /* home address option */ #define IPV6_TLV_HAO 201 /* home address option */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -169,7 +169,6 @@ enum
IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST, IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
IPV4_DEVCONF_DROP_GRATUITOUS_ARP, IPV4_DEVCONF_DROP_GRATUITOUS_ARP,
IPV4_DEVCONF_BC_FORWARDING, IPV4_DEVCONF_BC_FORWARDING,
IPV4_DEVCONF_ARP_EVICT_NOCARRIER,
__IPV4_DEVCONF_MAX __IPV4_DEVCONF_MAX
}; };

View File

@ -14,7 +14,6 @@ enum lwtunnel_encap_types {
LWTUNNEL_ENCAP_BPF, LWTUNNEL_ENCAP_BPF,
LWTUNNEL_ENCAP_SEG6_LOCAL, LWTUNNEL_ENCAP_SEG6_LOCAL,
LWTUNNEL_ENCAP_RPL, LWTUNNEL_ENCAP_RPL,
LWTUNNEL_ENCAP_IOAM6,
__LWTUNNEL_ENCAP_MAX, __LWTUNNEL_ENCAP_MAX,
}; };

View File

@ -97,6 +97,5 @@
#define DEVMEM_MAGIC 0x454d444d /* "DMEM" */ #define DEVMEM_MAGIC 0x454d444d /* "DMEM" */
#define Z3FOLD_MAGIC 0x33 #define Z3FOLD_MAGIC 0x33
#define PPC_CMM_MAGIC 0xc7571590 #define PPC_CMM_MAGIC 0xc7571590
#define SECRETMEM_MAGIC 0x5345434d /* "SECM" */
#endif /* __LINUX_MAGIC_H__ */ #endif /* __LINUX_MAGIC_H__ */

View File

@ -4,11 +4,6 @@
#include <linux/const.h> #include <linux/const.h>
#include <linux/types.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_REM _BITUL(0)
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1) #define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
@ -78,7 +73,6 @@ enum {
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0) #define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) #define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) #define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
enum { enum {
MPTCP_PM_CMD_UNSPEC, MPTCP_PM_CMD_UNSPEC,
@ -111,7 +105,6 @@ struct mptcp_info {
__u64 mptcpi_rcv_nxt; __u64 mptcpi_rcv_nxt;
__u8 mptcpi_local_addr_used; __u8 mptcpi_local_addr_used;
__u8 mptcpi_local_addr_max; __u8 mptcpi_local_addr_max;
__u8 mptcpi_csum_enabled;
}; };
/* /*
@ -181,49 +174,10 @@ enum mptcp_event_attr {
MPTCP_ATTR_FLAGS, /* u16 */ MPTCP_ATTR_FLAGS, /* u16 */
MPTCP_ATTR_TIMEOUT, /* u32 */ MPTCP_ATTR_TIMEOUT, /* u32 */
MPTCP_ATTR_IF_IDX, /* s32 */ MPTCP_ATTR_IF_IDX, /* s32 */
MPTCP_ATTR_RESET_REASON,/* u32 */
MPTCP_ATTR_RESET_FLAGS, /* u32 */
__MPTCP_ATTR_AFTER_LAST __MPTCP_ATTR_AFTER_LAST
}; };
#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1) #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 */ #endif /* _MPTCP_H */

View File

@ -31,7 +31,6 @@ enum {
NDA_PROTOCOL, /* Originator of entry */ NDA_PROTOCOL, /* Originator of entry */
NDA_NH_ID, NDA_NH_ID,
NDA_FDB_EXT_ATTRS, NDA_FDB_EXT_ATTRS,
NDA_FLAGS_EXT,
__NDA_MAX __NDA_MAX
}; };
@ -41,16 +40,14 @@ enum {
* Neighbor Cache Entry Flags * Neighbor Cache Entry Flags
*/ */
#define NTF_USE (1 << 0) #define NTF_USE 0x01
#define NTF_SELF (1 << 1) #define NTF_SELF 0x02
#define NTF_MASTER (1 << 2) #define NTF_MASTER 0x04
#define NTF_PROXY (1 << 3) /* == ATF_PUBL */ #define NTF_PROXY 0x08 /* == ATF_PUBL */
#define NTF_EXT_LEARNED (1 << 4) #define NTF_EXT_LEARNED 0x10
#define NTF_OFFLOADED (1 << 5) #define NTF_OFFLOADED 0x20
#define NTF_STICKY (1 << 6) #define NTF_STICKY 0x40
#define NTF_ROUTER (1 << 7) #define NTF_ROUTER 0x80
/* Extended flags under NDA_FLAGS_EXT: */
#define NTF_EXT_MANAGED (1 << 0)
/* /*
* Neighbor Cache Entry States. * Neighbor Cache Entry States.
@ -68,22 +65,9 @@ enum {
#define NUD_PERMANENT 0x80 #define NUD_PERMANENT 0x80
#define NUD_NONE 0x00 #define NUD_NONE 0x00
/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change and make no /* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change
* address resolution or NUD. and make no address resolution or NUD.
* NUD_PERMANENT also cannot be deleted by garbage collectors.
* 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.
*/ */
struct nda_cacheinfo { struct nda_cacheinfo {

View File

@ -49,7 +49,6 @@ enum nf_inet_hooks {
enum nf_dev_hooks { enum nf_dev_hooks {
NF_NETDEV_INGRESS, NF_NETDEV_INGRESS,
NF_NETDEV_EGRESS,
NF_NETDEV_NUMHOOKS NF_NETDEV_NUMHOOKS
}; };

View File

@ -91,10 +91,9 @@ struct nlmsghdr {
#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN) #define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)
#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) #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), \ #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
(struct nlmsghdr *)(((char *)(nlh)) + \ (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
NLMSG_ALIGN((nlh)->nlmsg_len)))
#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len <= (len)) (nlh)->nlmsg_len <= (len))

View File

@ -21,10 +21,7 @@ struct nexthop_grp {
}; };
enum { enum {
NEXTHOP_GRP_TYPE_MPATH, /* hash-threshold nexthop group NEXTHOP_GRP_TYPE_MPATH, /* default type if not specified */
* default type if not specified
*/
NEXTHOP_GRP_TYPE_RES, /* resilient nexthop group */
__NEXTHOP_GRP_TYPE_MAX, __NEXTHOP_GRP_TYPE_MAX,
}; };
@ -55,50 +52,8 @@ enum {
NHA_FDB, /* flag; nexthop belongs to a bridge fdb */ NHA_FDB, /* flag; nexthop belongs to a bridge fdb */
/* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */ /* 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, __NHA_MAX,
}; };
#define NHA_MAX (__NHA_MAX - 1) #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 #endif

View File

@ -22,7 +22,6 @@ enum {
__TCA_ACT_MAX __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 #define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for
* actions stats. * actions stats.
*/ */
@ -191,8 +190,6 @@ enum {
TCA_POLICE_PAD, TCA_POLICE_PAD,
TCA_POLICE_RATE64, TCA_POLICE_RATE64,
TCA_POLICE_PEAKRATE64, TCA_POLICE_PEAKRATE64,
TCA_POLICE_PKTRATE64,
TCA_POLICE_PKTBURST64,
__TCA_POLICE_MAX __TCA_POLICE_MAX
#define TCA_POLICE_RESULT TCA_POLICE_RESULT #define TCA_POLICE_RESULT TCA_POLICE_RESULT
}; };

View File

@ -827,8 +827,6 @@ struct tc_codel_xstats {
/* FQ_CODEL */ /* FQ_CODEL */
#define FQ_CODEL_QUANTUM_MAX (1 << 20)
enum { enum {
TCA_FQ_CODEL_UNSPEC, TCA_FQ_CODEL_UNSPEC,
TCA_FQ_CODEL_TARGET, TCA_FQ_CODEL_TARGET,
@ -840,8 +838,6 @@ enum {
TCA_FQ_CODEL_CE_THRESHOLD, TCA_FQ_CODEL_CE_THRESHOLD,
TCA_FQ_CODEL_DROP_BATCH_SIZE, TCA_FQ_CODEL_DROP_BATCH_SIZE,
TCA_FQ_CODEL_MEMORY_LIMIT, TCA_FQ_CODEL_MEMORY_LIMIT,
TCA_FQ_CODEL_CE_THRESHOLD_SELECTOR,
TCA_FQ_CODEL_CE_THRESHOLD_MASK,
__TCA_FQ_CODEL_MAX __TCA_FQ_CODEL_MAX
}; };

View File

@ -178,13 +178,6 @@ enum {
RTM_GETVLAN, RTM_GETVLAN,
#define RTM_GETVLAN 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, __RTM_MAX,
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
}; };
@ -290,7 +283,6 @@ enum {
#define RTPROT_MROUTED 17 /* Multicast daemon */ #define RTPROT_MROUTED 17 /* Multicast daemon */
#define RTPROT_KEEPALIVED 18 /* Keepalived daemon */ #define RTPROT_KEEPALIVED 18 /* Keepalived daemon */
#define RTPROT_BABEL 42 /* Babel daemon */ #define RTPROT_BABEL 42 /* Babel daemon */
#define RTPROT_OPENR 99 /* Open Routing (Open/R) Routes */
#define RTPROT_BGP 186 /* BGP Routes */ #define RTPROT_BGP 186 /* BGP Routes */
#define RTPROT_ISIS 187 /* ISIS Routes */ #define RTPROT_ISIS 187 /* ISIS Routes */
#define RTPROT_OSPF 188 /* OSPF Routes */ #define RTPROT_OSPF 188 /* OSPF Routes */

View File

@ -141,7 +141,6 @@ typedef __s32 sctp_assoc_t;
#define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE 131 #define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE 131
#define SCTP_EXPOSE_PF_STATE SCTP_EXPOSE_POTENTIALLY_FAILED_STATE #define SCTP_EXPOSE_PF_STATE SCTP_EXPOSE_POTENTIALLY_FAILED_STATE
#define SCTP_REMOTE_UDP_ENCAPS_PORT 132 #define SCTP_REMOTE_UDP_ENCAPS_PORT 132
#define SCTP_PLPMTUD_PROBE_INTERVAL 133
/* PR-SCTP policies */ /* PR-SCTP policies */
#define SCTP_PR_SCTP_NONE 0x0000 #define SCTP_PR_SCTP_NONE 0x0000
@ -1208,11 +1207,4 @@ enum sctp_sched_type {
SCTP_SS_MAX = SCTP_SS_RR 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 */ #endif /* _SCTP_H */

View File

@ -27,7 +27,6 @@ enum {
SEG6_LOCAL_OIF, SEG6_LOCAL_OIF,
SEG6_LOCAL_BPF, SEG6_LOCAL_BPF,
SEG6_LOCAL_VRFTABLE, SEG6_LOCAL_VRFTABLE,
SEG6_LOCAL_COUNTERS,
__SEG6_LOCAL_MAX, __SEG6_LOCAL_MAX,
}; };
#define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1) #define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1)
@ -64,8 +63,6 @@ enum {
SEG6_LOCAL_ACTION_END_AM = 14, SEG6_LOCAL_ACTION_END_AM = 14,
/* custom BPF action */ /* custom BPF action */
SEG6_LOCAL_ACTION_END_BPF = 15, 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, __SEG6_LOCAL_ACTION_MAX,
}; };
@ -81,33 +78,4 @@ enum {
#define SEG6_LOCAL_BPF_PROG_MAX (__SEG6_LOCAL_BPF_PROG_MAX - 1) #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 #endif

View File

@ -290,8 +290,6 @@ enum
LINUX_MIB_TCPDUPLICATEDATAREHASH, /* TCPDuplicateDataRehash */ LINUX_MIB_TCPDUPLICATEDATAREHASH, /* TCPDuplicateDataRehash */
LINUX_MIB_TCPDSACKRECVSEGS, /* TCPDSACKRecvSegs */ LINUX_MIB_TCPDSACKRECVSEGS, /* TCPDSACKRecvSegs */
LINUX_MIB_TCPDSACKIGNOREDDUBIOUS, /* TCPDSACKIgnoredDubious */ LINUX_MIB_TCPDSACKIGNOREDDUBIOUS, /* TCPDSACKIgnoredDubious */
LINUX_MIB_TCPMIGRATEREQSUCCESS, /* TCPMigrateReqSuccess */
LINUX_MIB_TCPMIGRATEREQFAILURE, /* TCPMigrateReqFailure */
__LINUX_MIB_MAX __LINUX_MIB_MAX
}; };

View File

@ -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 */ #endif /* _LINUX_SOCKET_H */

View File

@ -4,40 +4,3 @@
#ifndef __always_inline #ifndef __always_inline
#define __always_inline __inline__ #define __always_inline __inline__
#endif #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[]; \
}

View File

@ -17,7 +17,6 @@
#define SKBMOD_F_SMAC 0x2 #define SKBMOD_F_SMAC 0x2
#define SKBMOD_F_ETYPE 0x4 #define SKBMOD_F_ETYPE 0x4
#define SKBMOD_F_SWAPMAC 0x8 #define SKBMOD_F_SWAPMAC 0x8
#define SKBMOD_F_ECN 0x10
struct tc_skbmod { struct tc_skbmod {
tc_gen; tc_gen;

View File

@ -84,20 +84,6 @@
#define TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE 16 #define TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE 16
#define TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE 8 #define TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE 8
#define TLS_CIPHER_SM4_GCM 55
#define TLS_CIPHER_SM4_GCM_IV_SIZE 8
#define TLS_CIPHER_SM4_GCM_KEY_SIZE 16
#define TLS_CIPHER_SM4_GCM_SALT_SIZE 4
#define TLS_CIPHER_SM4_GCM_TAG_SIZE 16
#define TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE 8
#define TLS_CIPHER_SM4_CCM 56
#define TLS_CIPHER_SM4_CCM_IV_SIZE 8
#define TLS_CIPHER_SM4_CCM_KEY_SIZE 16
#define TLS_CIPHER_SM4_CCM_SALT_SIZE 4
#define TLS_CIPHER_SM4_CCM_TAG_SIZE 16
#define TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE 8
#define TLS_SET_RECORD_TYPE 1 #define TLS_SET_RECORD_TYPE 1
#define TLS_GET_RECORD_TYPE 2 #define TLS_GET_RECORD_TYPE 2
@ -138,22 +124,6 @@ struct tls12_crypto_info_chacha20_poly1305 {
unsigned char rec_seq[TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE]; unsigned char rec_seq[TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE];
}; };
struct tls12_crypto_info_sm4_gcm {
struct tls_crypto_info info;
unsigned char iv[TLS_CIPHER_SM4_GCM_IV_SIZE];
unsigned char key[TLS_CIPHER_SM4_GCM_KEY_SIZE];
unsigned char salt[TLS_CIPHER_SM4_GCM_SALT_SIZE];
unsigned char rec_seq[TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE];
};
struct tls12_crypto_info_sm4_ccm {
struct tls_crypto_info info;
unsigned char iv[TLS_CIPHER_SM4_CCM_IV_SIZE];
unsigned char key[TLS_CIPHER_SM4_CCM_KEY_SIZE];
unsigned char salt[TLS_CIPHER_SM4_CCM_SALT_SIZE];
unsigned char rec_seq[TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE];
};
enum { enum {
TLS_INFO_UNSPEC, TLS_INFO_UNSPEC,
TLS_INFO_VERSION, TLS_INFO_VERSION,

40
include/uapi/linux/vdpa.h Normal file
View File

@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* vdpa device management interface
* Copyright (c) 2020 Mellanox Technologies Ltd. All rights reserved.
*/
#ifndef _LINUX_VDPA_H_
#define _LINUX_VDPA_H_
#define VDPA_GENL_NAME "vdpa"
#define VDPA_GENL_VERSION 0x1
enum vdpa_command {
VDPA_CMD_UNSPEC,
VDPA_CMD_MGMTDEV_NEW,
VDPA_CMD_MGMTDEV_GET, /* can dump */
VDPA_CMD_DEV_NEW,
VDPA_CMD_DEV_DEL,
VDPA_CMD_DEV_GET, /* can dump */
};
enum vdpa_attr {
VDPA_ATTR_UNSPEC,
/* bus name (optional) + dev name together make the parent device handle */
VDPA_ATTR_MGMTDEV_BUS_NAME, /* string */
VDPA_ATTR_MGMTDEV_DEV_NAME, /* string */
VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES, /* u64 */
VDPA_ATTR_DEV_NAME, /* string */
VDPA_ATTR_DEV_ID, /* u32 */
VDPA_ATTR_DEV_VENDOR_ID, /* u32 */
VDPA_ATTR_DEV_MAX_VQS, /* u32 */
VDPA_ATTR_DEV_MAX_VQ_SIZE, /* u16 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,
};
#endif

View File

@ -51,34 +51,8 @@
#define VIRTIO_ID_PSTORE 22 /* virtio pstore device */ #define VIRTIO_ID_PSTORE 22 /* virtio pstore device */
#define VIRTIO_ID_IOMMU 23 /* virtio IOMMU */ #define VIRTIO_ID_IOMMU 23 /* virtio IOMMU */
#define VIRTIO_ID_MEM 24 /* virtio mem */ #define VIRTIO_ID_MEM 24 /* virtio mem */
#define VIRTIO_ID_SOUND 25 /* virtio sound */
#define VIRTIO_ID_FS 26 /* virtio filesystem */ #define VIRTIO_ID_FS 26 /* virtio filesystem */
#define VIRTIO_ID_PMEM 27 /* virtio pmem */ #define VIRTIO_ID_PMEM 27 /* virtio pmem */
#define VIRTIO_ID_RPMB 28 /* virtio rpmb */
#define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */ #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
#define VIRTIO_ID_VIDEO_ENCODER 30 /* virtio video encoder */
#define VIRTIO_ID_VIDEO_DECODER 31 /* virtio video decoder */
#define VIRTIO_ID_SCMI 32 /* virtio SCMI */
#define VIRTIO_ID_NITRO_SEC_MOD 33 /* virtio nitro secure module*/
#define VIRTIO_ID_I2C_ADAPTER 34 /* virtio i2c adapter */
#define VIRTIO_ID_WATCHDOG 35 /* virtio watchdog */
#define VIRTIO_ID_CAN 36 /* virtio can */
#define VIRTIO_ID_DMABUF 37 /* virtio dmabuf */
#define VIRTIO_ID_PARAM_SERV 38 /* virtio parameter server */
#define VIRTIO_ID_AUDIO_POLICY 39 /* virtio audio policy */
#define VIRTIO_ID_BT 40 /* virtio bluetooth */
#define VIRTIO_ID_GPIO 41 /* virtio gpio */
/*
* Virtio Transitional IDs
*/
#define VIRTIO_TRANS_ID_NET 1000 /* transitional virtio net */
#define VIRTIO_TRANS_ID_BLOCK 1001 /* transitional virtio block */
#define VIRTIO_TRANS_ID_BALLOON 1002 /* transitional virtio balloon */
#define VIRTIO_TRANS_ID_CONSOLE 1003 /* transitional virtio console */
#define VIRTIO_TRANS_ID_SCSI 1004 /* transitional virtio SCSI */
#define VIRTIO_TRANS_ID_RNG 1005 /* transitional virtio rng */
#define VIRTIO_TRANS_ID_9P 1009 /* transitional virtio 9p console */
#endif /* _LINUX_VIRTIO_IDS_H */ #endif /* _LINUX_VIRTIO_IDS_H */

View File

@ -1,16 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
* Copyright (C) 2021 Intel Corporation.
*/
#ifndef _WWAN_H_
#define _WWAN_H_
enum {
IFLA_WWAN_UNSPEC,
IFLA_WWAN_LINK_ID, /* u32 */
__IFLA_WWAN_MAX
};
#define IFLA_WWAN_MAX (__IFLA_WWAN_MAX - 1)
#endif /* _WWAN_H_ */

View File

@ -215,11 +215,6 @@ enum {
XFRM_MSG_MAPPING, XFRM_MSG_MAPPING,
#define XFRM_MSG_MAPPING XFRM_MSG_MAPPING #define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
XFRM_MSG_SETDEFAULT,
#define XFRM_MSG_SETDEFAULT XFRM_MSG_SETDEFAULT
XFRM_MSG_GETDEFAULT,
#define XFRM_MSG_GETDEFAULT XFRM_MSG_GETDEFAULT
__XFRM_MSG_MAX __XFRM_MSG_MAX
}; };
#define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1) #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
@ -513,15 +508,6 @@ struct xfrm_user_offload {
#define XFRM_OFFLOAD_IPV6 1 #define XFRM_OFFLOAD_IPV6 1
#define XFRM_OFFLOAD_INBOUND 2 #define XFRM_OFFLOAD_INBOUND 2
struct xfrm_userpolicy_default {
#define XFRM_USERPOLICY_UNSPEC 0
#define XFRM_USERPOLICY_BLOCK 1
#define XFRM_USERPOLICY_ACCEPT 2
__u8 in;
__u8 fwd;
__u8 out;
};
/* backwards compatibility for userspace */ /* backwards compatibility for userspace */
#define XFRMGRP_ACQUIRE 1 #define XFRMGRP_ACQUIRE 1
#define XFRMGRP_EXPIRE 2 #define XFRMGRP_EXPIRE 2

View File

@ -8,7 +8,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#include <stdint.h>
#ifdef HAVE_LIBBSD #ifdef HAVE_LIBBSD
#include <bsd/string.h> #include <bsd/string.h>
@ -51,9 +50,6 @@ void incomplete_command(void) __attribute__((noreturn));
#define NEXT_ARG_FWD() do { argv++; argc--; } while(0) #define NEXT_ARG_FWD() do { argv++; argc--; } while(0)
#define PREV_ARG() do { argv--; argc++; } while(0) #define PREV_ARG() do { argv--; argc++; } while(0)
/* Upper limit for batch mode */
#define MAX_ARGS 512
#define TIME_UNITS_PER_SEC 1000000 #define TIME_UNITS_PER_SEC 1000000
#define NSEC_PER_USEC 1000 #define NSEC_PER_USEC 1000
#define NSEC_PER_MSEC 1000000 #define NSEC_PER_MSEC 1000000
@ -109,6 +105,17 @@ static inline bool is_addrtype_inet_not_multi(const inet_prefix *p)
return (p->flags & ADDRTYPE_INET_MULTI) == ADDRTYPE_INET; return (p->flags & ADDRTYPE_INET_MULTI) == ADDRTYPE_INET;
} }
#define DN_MAXADDL 20
#ifndef AF_DECnet
#define AF_DECnet 12
#endif
struct dn_naddr
{
unsigned short a_len;
unsigned char a_addr[DN_MAXADDL];
};
#ifndef AF_MPLS #ifndef AF_MPLS
# define AF_MPLS 28 # define AF_MPLS 28
#endif #endif
@ -198,15 +205,9 @@ bool matches(const char *prefix, const char *string);
int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits); int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits);
int inet_addr_match_rta(const inet_prefix *m, const struct rtattr *rta); int inet_addr_match_rta(const inet_prefix *m, const struct rtattr *rta);
const char *ax25_ntop(int af, const void *addr, char *str, socklen_t len);
const char *rose_ntop(int af, const void *addr, char *buf, socklen_t buflen);
const char *mpls_ntop(int af, const void *addr, char *str, size_t len); const char *mpls_ntop(int af, const void *addr, char *str, size_t len);
int mpls_pton(int af, const char *src, void *addr, size_t alen); int mpls_pton(int af, const char *src, void *addr, size_t alen);
const char *netrom_ntop(int af, const void *addr, char *str, socklen_t len);
extern int __iproute2_hz_internal; extern int __iproute2_hz_internal;
int __get_hz(void); int __get_hz(void);
@ -263,7 +264,7 @@ void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n);
unsigned int print_name_and_link(const char *fmt, unsigned int print_name_and_link(const char *fmt,
const char *name, struct rtattr *tb[]); const char *name, struct rtattr *tb[]);
#define BIT(nr) (UINT64_C(1) << (nr)) #define BIT(nr) (1UL << (nr))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
@ -307,7 +308,6 @@ char *find_cgroup2_mount(bool do_mount);
__u64 get_cgroup2_id(const char *path); __u64 get_cgroup2_id(const char *path);
char *get_cgroup2_path(__u64 id, bool full); char *get_cgroup2_path(__u64 id, bool full);
int get_command_name(const char *pid, char *comm, size_t len); int get_command_name(const char *pid, char *comm, size_t len);
char *get_task_name(pid_t pid);
int get_rtnl_link_stats_rta(struct rtnl_link_stats64 *stats64, int get_rtnl_link_stats_rta(struct rtnl_link_stats64 *stats64,
struct rtattr *tb[]); struct rtattr *tb[]);

View File

@ -1 +1 @@
static const char version[] = "5.15.0"; static const char version[] = "5.12.0";

View File

@ -11,15 +11,14 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \ iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \ iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \
ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o \ ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o \
ipnexthop.o ipmptcp.o iplink_bareudp.o iplink_wwan.o ipioam6.o \ ipnexthop.o ipmptcp.o iplink_bareudp.o
iplink_amt.o
RTMONOBJ=rtmon.o RTMONOBJ=rtmon.o
include ../config.mk include ../config.mk
ALLOBJ=$(IPOBJ) $(RTMONOBJ) ALLOBJ=$(IPOBJ) $(RTMONOBJ)
SCRIPTS=routel SCRIPTS=ifcfg rtpr routel routef
TARGETS=ip rtmon TARGETS=ip rtmon
all: $(TARGETS) $(SCRIPTS) all: $(TARGETS) $(SCRIPTS)

150
ip/ifcfg Executable file
View File

@ -0,0 +1,150 @@
#! /bin/sh
# SPDX-License-Identifier: GPL-2.0
CheckForwarding () {
local sbase fwd
sbase=/proc/sys/net/ipv4/conf
fwd=0
if [ -d $sbase ]; then
for dir in $sbase/*/forwarding; do
fwd=$(( fwd + $(cat "$dir") ))
done
else
fwd=2
fi
return $fwd
}
RestartRDISC () {
killall -HUP rdisc || rdisc -fs
}
ABCMaskLen () {
local class;
class=${1%%.*}
if [ "$1" = "" -o $class -eq 0 -o $class -ge 224 ]; then return 0
elif [ $class -ge 224 ]; then return 0
elif [ $class -ge 192 ]; then return 24
elif [ $class -ge 128 ]; then return 16
else return 8; fi
}
label="label $1"
ldev="$1"
dev=${1%:*}
if [ "$dev" = "" -o "$1" = "help" ]; then
echo "Usage: ifcfg DEV [[add|del [ADDR[/LEN]] [PEER] | stop]" 1>&2
echo " add - add new address" 1>&2
echo " del - delete address" 1>&2
echo " stop - completely disable IP" 1>&2
exit 1
fi
shift
CheckForwarding
fwd=$?
if [ $fwd -ne 0 ]; then
echo "Forwarding is ON or its state is unknown ($fwd). OK, No RDISC." 1>&2
fi
deleting=0
case "$1" in
add) shift ;;
stop)
if [ "$ldev" != "$dev" ]; then
echo "Cannot stop alias $ldev" 1>&2
exit 1;
fi
ip -4 addr flush dev $dev $label || exit 1
if [ $fwd -eq 0 ]; then RestartRDISC; fi
exit 0 ;;
del*)
deleting=1; shift ;;
*)
esac
ipaddr=
pfxlen=
if [ "$1" != "" ]; then
ipaddr=${1%/*}
if [ "$1" != "$ipaddr" ]; then
pfxlen=${1#*/}
fi
if [ "$ipaddr" = "" ]; then
echo "$1 is bad IP address." 1>&2
exit 1
fi
fi
shift
peer=$1
if [ "$peer" != "" ]; then
if [ "$pfxlen" != "" -a "$pfxlen" != "32" ]; then
echo "Peer address with non-trivial netmask." 1>&2
exit 1
fi
pfx="$ipaddr peer $peer"
else
if [ "$ipaddr" = "" ]; then
echo "Missing IP address argument." 1>&2
exit 1
fi
if [ "$pfxlen" = "" ]; then
ABCMaskLen $ipaddr
pfxlen=$?
fi
pfx="$ipaddr/$pfxlen"
fi
if [ "$ldev" = "$dev" -a "$ipaddr" != "" ]; then
label=
fi
if [ $deleting -ne 0 ]; then
ip addr del $pfx dev $dev $label || exit 1
if [ $fwd -eq 0 ]; then RestartRDISC; fi
exit 0
fi
if ! ip link set up dev $dev ; then
echo "Error: cannot enable interface $dev." 1>&2
exit 1
fi
if [ "$ipaddr" = "" ]; then exit 0; fi
if ! arping -q -c 2 -w 3 -D -I $dev $ipaddr ; then
echo "Error: some host already uses address $ipaddr on $dev." 1>&2
exit 1
fi
if ! ip address add $pfx brd + dev $dev $label; then
echo "Error: failed to add $pfx on $dev." 1>&2
exit 1
fi
arping -q -A -c 1 -I $dev $ipaddr
noarp=$?
( sleep 2 ;
arping -q -U -c 1 -I $dev $ipaddr ) >/dev/null 2>&1 </dev/null &
ip route add unreachable 224.0.0.0/24 >/dev/null 2>&1
ip route add unreachable 255.255.255.255 >/dev/null 2>&1
if [ "`ip link ls $dev | grep -c MULTICAST`" -ge 1 ]; then
ip route add 224.0.0.0/4 dev $dev scope global >/dev/null 2>&1
fi
if [ $fwd -eq 0 ]; then
if [ $noarp -eq 0 ]; then
ip ro append default dev $dev metric 30000 scope global
elif [ "$peer" != "" ]; then
if ping -q -c 2 -w 4 $peer ; then
ip ro append default via $peer dev $dev metric 30001
fi
fi
RestartRDISC
fi
exit 0

25
ip/ip.c
View File

@ -64,15 +64,15 @@ static void usage(void)
fprintf(stderr, fprintf(stderr,
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n" "Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
" ip [ -force ] -batch filename\n" " ip [ -force ] -batch filename\n"
"where OBJECT := { address | addrlabel | amt | fou | help | ila | ioam | l2tp |\n" "where OBJECT := { address | addrlabel | fou | help | ila | l2tp | link |\n"
" link | macsec | maddress | monitor | mptcp | mroute | mrule |\n" " macsec | maddress | monitor | mptcp | mroute | mrule |\n"
" neighbor | neighbour | netconf | netns | nexthop | ntable |\n" " neighbor | neighbour | netconf | netns | nexthop | ntable |\n"
" ntbl | route | rule | sr | tap | tcpmetrics |\n" " ntbl | route | rule | sr | tap | tcpmetrics |\n"
" token | tunnel | tuntap | vrf | xfrm }\n" " token | tunnel | tuntap | vrf | xfrm }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n" " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
" -h[uman-readable] | -iec | -j[son] | -p[retty] |\n" " -h[uman-readable] | -iec | -j[son] | -p[retty] |\n"
" -f[amily] { inet | inet6 | mpls | bridge | link } |\n" " -f[amily] { inet | inet6 | mpls | bridge | link } |\n"
" -4 | -6 | -M | -B | -0 |\n" " -4 | -6 | -I | -D | -M | -B | -0 |\n"
" -l[oops] { maximum-addr-flush-attempts } | -br[ief] |\n" " -l[oops] { maximum-addr-flush-attempts } | -br[ief] |\n"
" -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |\n" " -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |\n"
" -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |\n" " -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |\n"
@ -121,12 +121,11 @@ static const struct cmd {
{ "sr", do_seg6 }, { "sr", do_seg6 },
{ "nexthop", do_ipnh }, { "nexthop", do_ipnh },
{ "mptcp", do_mptcp }, { "mptcp", do_mptcp },
{ "ioam", do_ioam6 },
{ "help", do_help }, { "help", do_help },
{ 0 } { 0 }
}; };
static int do_cmd(const char *argv0, int argc, char **argv, bool final) static int do_cmd(const char *argv0, int argc, char **argv)
{ {
const struct cmd *c; const struct cmd *c;
@ -135,8 +134,7 @@ static int do_cmd(const char *argv0, int argc, char **argv, bool final)
return -(c->func(argc-1, argv+1)); return -(c->func(argc-1, argv+1));
} }
if (final) fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -145,7 +143,7 @@ static int ip_batch_cmd(int argc, char *argv[], void *data)
const int *orig_family = data; const int *orig_family = data;
preferred_family = *orig_family; preferred_family = *orig_family;
return do_cmd(argv[0], argc, argv, true); return do_cmd(argv[0], argc, argv);
} }
static int batch(const char *name) static int batch(const char *name)
@ -224,6 +222,8 @@ int main(int argc, char **argv)
preferred_family = AF_INET6; preferred_family = AF_INET6;
} else if (strcmp(opt, "-0") == 0) { } else if (strcmp(opt, "-0") == 0) {
preferred_family = AF_PACKET; preferred_family = AF_PACKET;
} else if (strcmp(opt, "-D") == 0) {
preferred_family = AF_DECnet;
} else if (strcmp(opt, "-M") == 0) { } else if (strcmp(opt, "-M") == 0) {
preferred_family = AF_MPLS; preferred_family = AF_MPLS;
} else if (strcmp(opt, "-B") == 0) { } else if (strcmp(opt, "-B") == 0) {
@ -313,14 +313,11 @@ int main(int argc, char **argv)
rtnl_set_strict_dump(&rth); rtnl_set_strict_dump(&rth);
if (strlen(basename) > 2) { if (strlen(basename) > 2)
int ret = do_cmd(basename+2, argc, argv, false); return do_cmd(basename+2, argc, argv);
if (ret != EXIT_FAILURE)
return ret;
}
if (argc > 1) if (argc > 1)
return do_cmd(argv[1], argc-1, argv+1, true); return do_cmd(argv[1], argc-1, argv+1);
rtnl_close(&rth); rtnl_close(&rth);
usage(); usage();

View File

@ -53,7 +53,7 @@ int print_prefix(struct nlmsghdr *n, void *arg);
int print_rule(struct nlmsghdr *n, void *arg); int print_rule(struct nlmsghdr *n, void *arg);
int print_netconf(struct rtnl_ctrl_data *ctrl, int print_netconf(struct rtnl_ctrl_data *ctrl,
struct nlmsghdr *n, void *arg); struct nlmsghdr *n, void *arg);
int print_nexthop_bucket(struct nlmsghdr *n, void *arg); int print_nexthop(struct nlmsghdr *n, void *arg);
void netns_map_init(void); void netns_map_init(void);
void netns_nsid_socket_init(void); void netns_nsid_socket_init(void);
int print_nsid(struct nlmsghdr *n, void *arg); int print_nsid(struct nlmsghdr *n, void *arg);
@ -89,7 +89,6 @@ int netns_identify_pid(const char *pidstr, char *name, int len);
int do_seg6(int argc, char **argv); int do_seg6(int argc, char **argv);
int do_ipnh(int argc, char **argv); int do_ipnh(int argc, char **argv);
int do_mptcp(int argc, char **argv); int do_mptcp(int argc, char **argv);
int do_ioam6(int argc, char **argv);
int iplink_get(char *name, __u32 filt_mask); int iplink_get(char *name, __u32 filt_mask);
int iplink_ifla_xstats(int argc, char **argv); int iplink_ifla_xstats(int argc, char **argv);
@ -167,8 +166,7 @@ int name_is_vrf(const char *name);
void print_num(FILE *fp, unsigned int width, uint64_t count); void print_num(FILE *fp, unsigned int width, uint64_t count);
void print_rt_flags(FILE *fp, unsigned int flags); void print_rt_flags(FILE *fp, unsigned int flags);
void print_rta_ifidx(FILE *fp, __u32 ifidx, const char *prefix); void print_rta_if(FILE *fp, const struct rtattr *rta, const char *prefix);
void __print_rta_gateway(FILE *fp, unsigned char family, const char *gateway);
void print_rta_gateway(FILE *fp, unsigned char family, void print_rta_gateway(FILE *fp, unsigned char family,
const struct rtattr *rta); const struct rtattr *rta);
#endif /* _IP_COMMON_H_ */ #endif /* _IP_COMMON_H_ */

View File

@ -10,7 +10,6 @@
* *
*/ */
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -60,7 +59,6 @@ static void usage(void)
" ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]\n" " ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]\n"
" [ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]\n" " [ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]\n"
" ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]\n" " ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]\n"
" [ nomaster ]\n"
" [ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]\n" " [ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]\n"
" [ label LABEL ] [up] [ vrf NAME ] ]\n" " [ label LABEL ] [up] [ vrf NAME ] ]\n"
" ip address {showdump|restore}\n" " ip address {showdump|restore}\n"
@ -546,29 +544,6 @@ static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
print_vf_stats64(fp, vf[IFLA_VF_STATS]); print_vf_stats64(fp, vf[IFLA_VF_STATS]);
} }
static void size_columns(unsigned int cols[], unsigned int n, ...)
{
unsigned int i, len;
uint64_t val, powi;
va_list args;
va_start(args, n);
for (i = 0; i < n; i++) {
val = va_arg(args, unsigned long long);
if (human_readable)
continue;
for (len = 1, powi = 10; powi < val; len++, powi *= 10)
/* nothing */;
if (len > cols[i])
cols[i] = len;
}
va_end(args);
}
void print_num(FILE *fp, unsigned int width, uint64_t count) void print_num(FILE *fp, unsigned int width, uint64_t count)
{ {
const char *prefix = "kMGTPE"; const char *prefix = "kMGTPE";
@ -579,7 +554,7 @@ void print_num(FILE *fp, unsigned int width, uint64_t count)
char buf[64]; char buf[64];
if (!human_readable || count < base) { if (!human_readable || count < base) {
fprintf(fp, "%*"PRIu64" ", width, count); fprintf(fp, "%-*"PRIu64" ", width, count);
return; return;
} }
@ -606,7 +581,7 @@ void print_num(FILE *fp, unsigned int width, uint64_t count)
snprintf(buf, sizeof(buf), "%.*f%c%s", precision, snprintf(buf, sizeof(buf), "%.*f%c%s", precision,
(double) count / powi, *prefix, use_iec ? "i" : ""); (double) count / powi, *prefix, use_iec ? "i" : "");
fprintf(fp, "%*s ", width, buf); fprintf(fp, "%-*s ", width, buf);
} }
static void print_vf_stats64(FILE *fp, struct rtattr *vfstats) static void print_vf_stats64(FILE *fp, struct rtattr *vfstats)
@ -684,15 +659,6 @@ static void __print_link_stats(FILE *fp, struct rtattr *tb[])
{ {
const struct rtattr *carrier_changes = tb[IFLA_CARRIER_CHANGES]; const struct rtattr *carrier_changes = tb[IFLA_CARRIER_CHANGES];
struct rtnl_link_stats64 _s, *s = &_s; struct rtnl_link_stats64 _s, *s = &_s;
unsigned int cols[] = {
strlen("*X errors:"),
strlen("packets"),
strlen("errors"),
strlen("dropped"),
strlen("heartbt"),
strlen("overrun"),
strlen("compressed"),
};
int ret; int ret;
ret = get_rtnl_link_stats_rta(s, tb); ret = get_rtnl_link_stats_rta(s, tb);
@ -773,98 +739,65 @@ static void __print_link_stats(FILE *fp, struct rtattr *tb[])
close_json_object(); close_json_object();
close_json_object(); close_json_object();
} else { } else {
size_columns(cols, ARRAY_SIZE(cols),
s->rx_bytes, s->rx_packets, s->rx_errors,
s->rx_dropped, s->rx_missed_errors,
s->multicast, s->rx_compressed);
if (show_stats > 1)
size_columns(cols, ARRAY_SIZE(cols), 0,
s->rx_length_errors, s->rx_crc_errors,
s->rx_frame_errors, s->rx_fifo_errors,
s->rx_over_errors, s->rx_nohandler);
size_columns(cols, ARRAY_SIZE(cols),
s->tx_bytes, s->tx_packets, s->tx_errors,
s->tx_dropped, s->tx_carrier_errors,
s->collisions, s->tx_compressed);
if (show_stats > 1)
size_columns(cols, ARRAY_SIZE(cols), 0, 0,
s->tx_aborted_errors, s->tx_fifo_errors,
s->tx_window_errors,
s->tx_heartbeat_errors,
carrier_changes ?
rta_getattr_u32(carrier_changes) : 0);
/* RX stats */ /* RX stats */
fprintf(fp, " RX: %*s %*s %*s %*s %*s %*s %*s%s", fprintf(fp, " RX: bytes packets errors dropped missed mcast %s%s",
cols[0] - 4, "bytes", cols[1], "packets", s->rx_compressed ? "compressed" : "", _SL_);
cols[2], "errors", cols[3], "dropped",
cols[4], "missed", cols[5], "mcast",
cols[6], s->rx_compressed ? "compressed" : "", _SL_);
fprintf(fp, " "); fprintf(fp, " ");
print_num(fp, cols[0], s->rx_bytes); print_num(fp, 10, s->rx_bytes);
print_num(fp, cols[1], s->rx_packets); print_num(fp, 8, s->rx_packets);
print_num(fp, cols[2], s->rx_errors); print_num(fp, 7, s->rx_errors);
print_num(fp, cols[3], s->rx_dropped); print_num(fp, 7, s->rx_dropped);
print_num(fp, cols[4], s->rx_missed_errors); print_num(fp, 7, s->rx_missed_errors);
print_num(fp, cols[5], s->multicast); print_num(fp, 7, s->multicast);
if (s->rx_compressed) if (s->rx_compressed)
print_num(fp, cols[6], s->rx_compressed); print_num(fp, 7, s->rx_compressed);
/* RX error stats */ /* RX error stats */
if (show_stats > 1) { if (show_stats > 1) {
fprintf(fp, "%s", _SL_); fprintf(fp, "%s", _SL_);
fprintf(fp, " RX errors:%*s %*s %*s %*s %*s %*s %*s%s", fprintf(fp, " RX errors: length crc frame fifo overrun%s%s",
cols[0] - 10, "", cols[1], "length", s->rx_nohandler ? " nohandler" : "", _SL_);
cols[2], "crc", cols[3], "frame", fprintf(fp, " ");
cols[4], "fifo", cols[5], "overrun", print_num(fp, 8, s->rx_length_errors);
cols[6], s->rx_nohandler ? "nohandler" : "", print_num(fp, 7, s->rx_crc_errors);
_SL_); print_num(fp, 7, s->rx_frame_errors);
fprintf(fp, "%*s", cols[0] + 5, ""); print_num(fp, 7, s->rx_fifo_errors);
print_num(fp, cols[1], s->rx_length_errors); print_num(fp, 7, s->rx_over_errors);
print_num(fp, cols[2], s->rx_crc_errors);
print_num(fp, cols[3], s->rx_frame_errors);
print_num(fp, cols[4], s->rx_fifo_errors);
print_num(fp, cols[5], s->rx_over_errors);
if (s->rx_nohandler) if (s->rx_nohandler)
print_num(fp, cols[6], s->rx_nohandler); print_num(fp, 7, s->rx_nohandler);
} }
fprintf(fp, "%s", _SL_); fprintf(fp, "%s", _SL_);
/* TX stats */ /* TX stats */
fprintf(fp, " TX: %*s %*s %*s %*s %*s %*s %*s%s", fprintf(fp, " TX: bytes packets errors dropped carrier collsns %s%s",
cols[0] - 4, "bytes", cols[1], "packets", s->tx_compressed ? "compressed" : "", _SL_);
cols[2], "errors", cols[3], "dropped",
cols[4], "carrier", cols[5], "collsns",
cols[6], s->tx_compressed ? "compressed" : "", _SL_);
fprintf(fp, " "); fprintf(fp, " ");
print_num(fp, cols[0], s->tx_bytes); print_num(fp, 10, s->tx_bytes);
print_num(fp, cols[1], s->tx_packets); print_num(fp, 8, s->tx_packets);
print_num(fp, cols[2], s->tx_errors); print_num(fp, 7, s->tx_errors);
print_num(fp, cols[3], s->tx_dropped); print_num(fp, 7, s->tx_dropped);
print_num(fp, cols[4], s->tx_carrier_errors); print_num(fp, 7, s->tx_carrier_errors);
print_num(fp, cols[5], s->collisions); print_num(fp, 7, s->collisions);
if (s->tx_compressed) if (s->tx_compressed)
print_num(fp, cols[6], s->tx_compressed); print_num(fp, 7, s->tx_compressed);
/* TX error stats */ /* TX error stats */
if (show_stats > 1) { if (show_stats > 1) {
fprintf(fp, "%s", _SL_); fprintf(fp, "%s", _SL_);
fprintf(fp, " TX errors:%*s %*s %*s %*s %*s %*s%s", fprintf(fp, " TX errors: aborted fifo window heartbeat");
cols[0] - 10, "", cols[1], "aborted",
cols[2], "fifo", cols[3], "window",
cols[4], "heartbt",
cols[5], carrier_changes ? "transns" : "",
_SL_);
fprintf(fp, "%*s", cols[0] + 5, "");
print_num(fp, cols[1], s->tx_aborted_errors);
print_num(fp, cols[2], s->tx_fifo_errors);
print_num(fp, cols[3], s->tx_window_errors);
print_num(fp, cols[4], s->tx_heartbeat_errors);
if (carrier_changes) if (carrier_changes)
print_num(fp, cols[5], fprintf(fp, " transns");
fprintf(fp, "%s", _SL_);
fprintf(fp, " ");
print_num(fp, 8, s->tx_aborted_errors);
print_num(fp, 7, s->tx_fifo_errors);
print_num(fp, 7, s->tx_window_errors);
print_num(fp, 7, s->tx_heartbeat_errors);
if (carrier_changes)
print_num(fp, 7,
rta_getattr_u32(carrier_changes)); rta_getattr_u32(carrier_changes));
} }
} }
@ -1243,20 +1176,6 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
RTA_PAYLOAD(tb[IFLA_PHYS_SWITCH_ID]), RTA_PAYLOAD(tb[IFLA_PHYS_SWITCH_ID]),
b1, sizeof(b1))); b1, sizeof(b1)));
} }
if (tb[IFLA_PARENT_DEV_BUS_NAME]) {
print_string(PRINT_ANY,
"parentbus",
"parentbus %s ",
rta_getattr_str(tb[IFLA_PARENT_DEV_BUS_NAME]));
}
if (tb[IFLA_PARENT_DEV_NAME]) {
print_string(PRINT_ANY,
"parentdev",
"parentdev %s ",
rta_getattr_str(tb[IFLA_PARENT_DEV_NAME]));
}
} }
if ((do_link || show_details) && tb[IFLA_IFALIAS]) { if ((do_link || show_details) && tb[IFLA_IFALIAS]) {
@ -2124,8 +2043,6 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
if (!name_is_vrf(*argv)) if (!name_is_vrf(*argv))
invarg("Not a valid VRF name\n", *argv); invarg("Not a valid VRF name\n", *argv);
filter.master = ifindex; filter.master = ifindex;
} else if (strcmp(*argv, "nomaster") == 0) {
filter.master = -1;
} else if (strcmp(*argv, "type") == 0) { } else if (strcmp(*argv, "type") == 0) {
int soff; int soff;

View File

@ -1,333 +0,0 @@
// SPDX-License-Identifier: GPL-2.0
/*
* ioam6.c "ip ioam"
*
* Author: Justin Iurman <justin.iurman@uliege.be>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <inttypes.h>
#include <linux/genetlink.h>
#include <linux/ioam6_genl.h>
#include "utils.h"
#include "ip_common.h"
#include "libgenl.h"
#include "json_print.h"
static void usage(void)
{
fprintf(stderr,
"Usage: ip ioam { COMMAND | help }\n"
" ip ioam namespace show\n"
" ip ioam namespace add ID [ data DATA32 ] [ wide DATA64 ]\n"
" ip ioam namespace del ID\n"
" ip ioam schema show\n"
" ip ioam schema add ID DATA\n"
" ip ioam schema del ID\n"
" ip ioam namespace set ID schema { ID | none }\n");
exit(-1);
}
static struct rtnl_handle grth = { .fd = -1 };
static int genl_family = -1;
#define IOAM6_REQUEST(_req, _bufsiz, _cmd, _flags) \
GENL_REQUEST(_req, _bufsiz, genl_family, 0, \
IOAM6_GENL_VERSION, _cmd, _flags)
static struct {
unsigned int cmd;
__u32 sc_id;
__u32 ns_data;
__u64 ns_data_wide;
__u16 ns_id;
bool has_ns_data;
bool has_ns_data_wide;
bool sc_none;
__u8 sc_data[IOAM6_MAX_SCHEMA_DATA_LEN];
} opts;
static void print_namespace(struct rtattr *attrs[])
{
print_uint(PRINT_ANY, "namespace", "namespace %u",
rta_getattr_u16(attrs[IOAM6_ATTR_NS_ID]));
if (attrs[IOAM6_ATTR_SC_ID])
print_uint(PRINT_ANY, "schema", " [schema %u]",
rta_getattr_u32(attrs[IOAM6_ATTR_SC_ID]));
if (attrs[IOAM6_ATTR_NS_DATA])
print_hex(PRINT_ANY, "data", ", data %#010x",
rta_getattr_u32(attrs[IOAM6_ATTR_NS_DATA]));
if (attrs[IOAM6_ATTR_NS_DATA_WIDE])
print_0xhex(PRINT_ANY, "wide", ", wide %#018lx",
rta_getattr_u64(attrs[IOAM6_ATTR_NS_DATA_WIDE]));
print_nl();
}
static void print_schema(struct rtattr *attrs[])
{
__u8 data[IOAM6_MAX_SCHEMA_DATA_LEN];
int len, i = 0;
print_uint(PRINT_ANY, "schema", "schema %u",
rta_getattr_u32(attrs[IOAM6_ATTR_SC_ID]));
if (attrs[IOAM6_ATTR_NS_ID])
print_uint(PRINT_ANY, "namespace", " [namespace %u]",
rta_getattr_u16(attrs[IOAM6_ATTR_NS_ID]));
len = RTA_PAYLOAD(attrs[IOAM6_ATTR_SC_DATA]);
memcpy(data, RTA_DATA(attrs[IOAM6_ATTR_SC_DATA]), len);
print_null(PRINT_ANY, "data", ", data:", NULL);
while (i < len) {
print_hhu(PRINT_ANY, "", " %02x", data[i]);
i++;
}
print_nl();
}
static int process_msg(struct nlmsghdr *n, void *arg)
{
struct rtattr *attrs[IOAM6_ATTR_MAX + 1];
struct genlmsghdr *ghdr;
int len = n->nlmsg_len;
if (n->nlmsg_type != genl_family)
return -1;
len -= NLMSG_LENGTH(GENL_HDRLEN);
if (len < 0)
return -1;
ghdr = NLMSG_DATA(n);
parse_rtattr(attrs, IOAM6_ATTR_MAX, (void *)ghdr + GENL_HDRLEN, len);
open_json_object(NULL);
switch (ghdr->cmd) {
case IOAM6_CMD_DUMP_NAMESPACES:
print_namespace(attrs);
break;
case IOAM6_CMD_DUMP_SCHEMAS:
print_schema(attrs);
break;
}
close_json_object();
return 0;
}
static int ioam6_do_cmd(void)
{
IOAM6_REQUEST(req, 1056, opts.cmd, NLM_F_REQUEST);
int dump = 0;
if (genl_init_handle(&grth, IOAM6_GENL_NAME, &genl_family))
exit(1);
req.n.nlmsg_type = genl_family;
switch (opts.cmd) {
case IOAM6_CMD_ADD_NAMESPACE:
addattr16(&req.n, sizeof(req), IOAM6_ATTR_NS_ID, opts.ns_id);
if (opts.has_ns_data)
addattr32(&req.n, sizeof(req), IOAM6_ATTR_NS_DATA,
opts.ns_data);
if (opts.has_ns_data_wide)
addattr64(&req.n, sizeof(req), IOAM6_ATTR_NS_DATA_WIDE,
opts.ns_data_wide);
break;
case IOAM6_CMD_DEL_NAMESPACE:
addattr16(&req.n, sizeof(req), IOAM6_ATTR_NS_ID, opts.ns_id);
break;
case IOAM6_CMD_DUMP_NAMESPACES:
case IOAM6_CMD_DUMP_SCHEMAS:
dump = 1;
break;
case IOAM6_CMD_ADD_SCHEMA:
addattr32(&req.n, sizeof(req), IOAM6_ATTR_SC_ID, opts.sc_id);
addattr_l(&req.n, sizeof(req), IOAM6_ATTR_SC_DATA, opts.sc_data,
strlen((const char *)opts.sc_data));
break;
case IOAM6_CMD_DEL_SCHEMA:
addattr32(&req.n, sizeof(req), IOAM6_ATTR_SC_ID, opts.sc_id);
break;
case IOAM6_CMD_NS_SET_SCHEMA:
addattr16(&req.n, sizeof(req), IOAM6_ATTR_NS_ID, opts.ns_id);
if (opts.sc_none)
addattr(&req.n, sizeof(req), IOAM6_ATTR_SC_NONE);
else
addattr32(&req.n, sizeof(req), IOAM6_ATTR_SC_ID,
opts.sc_id);
break;
}
if (!dump) {
if (rtnl_talk(&grth, &req.n, NULL) < 0)
return -1;
} else {
req.n.nlmsg_flags |= NLM_F_DUMP;
req.n.nlmsg_seq = grth.dump = ++grth.seq;
if (rtnl_send(&grth, &req, req.n.nlmsg_len) < 0) {
perror("Failed to send dump request");
exit(1);
}
new_json_obj(json);
if (rtnl_dump_filter(&grth, process_msg, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
}
delete_json_obj();
fflush(stdout);
}
return 0;
}
int do_ioam6(int argc, char **argv)
{
bool maybe_wide = false;
if (argc < 1 || strcmp(*argv, "help") == 0)
usage();
memset(&opts, 0, sizeof(opts));
if (strcmp(*argv, "namespace") == 0) {
NEXT_ARG();
if (strcmp(*argv, "show") == 0) {
opts.cmd = IOAM6_CMD_DUMP_NAMESPACES;
} else if (strcmp(*argv, "add") == 0) {
NEXT_ARG();
if (get_u16(&opts.ns_id, *argv, 0))
invarg("Invalid namespace ID", *argv);
if (NEXT_ARG_OK()) {
NEXT_ARG_FWD();
if (strcmp(*argv, "data") == 0) {
NEXT_ARG();
if (get_u32(&opts.ns_data, *argv, 0))
invarg("Invalid data", *argv);
maybe_wide = true;
opts.has_ns_data = true;
} else if (strcmp(*argv, "wide") == 0) {
NEXT_ARG();
if (get_u64(&opts.ns_data_wide, *argv, 16))
invarg("Invalid wide data", *argv);
opts.has_ns_data_wide = true;
} else {
invarg("Invalid argument", *argv);
}
}
if (NEXT_ARG_OK()) {
NEXT_ARG_FWD();
if (!maybe_wide || strcmp(*argv, "wide") != 0)
invarg("Unexpected argument", *argv);
NEXT_ARG();
if (get_u64(&opts.ns_data_wide, *argv, 16))
invarg("Invalid wide data", *argv);
opts.has_ns_data_wide = true;
}
opts.cmd = IOAM6_CMD_ADD_NAMESPACE;
} else if (strcmp(*argv, "del") == 0) {
NEXT_ARG();
if (get_u16(&opts.ns_id, *argv, 0))
invarg("Invalid namespace ID", *argv);
opts.cmd = IOAM6_CMD_DEL_NAMESPACE;
} else if (strcmp(*argv, "set") == 0) {
NEXT_ARG();
if (get_u16(&opts.ns_id, *argv, 0))
invarg("Invalid namespace ID", *argv);
NEXT_ARG();
if (strcmp(*argv, "schema") != 0)
invarg("Unknown", *argv);
NEXT_ARG();
if (strcmp(*argv, "none") == 0) {
opts.sc_none = true;
} else {
if (get_u32(&opts.sc_id, *argv, 0))
invarg("Invalid schema ID", *argv);
opts.sc_none = false;
}
opts.cmd = IOAM6_CMD_NS_SET_SCHEMA;
} else {
invarg("Unknown", *argv);
}
} else if (strcmp(*argv, "schema") == 0) {
NEXT_ARG();
if (strcmp(*argv, "show") == 0) {
opts.cmd = IOAM6_CMD_DUMP_SCHEMAS;
} else if (strcmp(*argv, "add") == 0) {
NEXT_ARG();
if (get_u32(&opts.sc_id, *argv, 0))
invarg("Invalid schema ID", *argv);
NEXT_ARG();
if (strlen(*argv) > IOAM6_MAX_SCHEMA_DATA_LEN)
invarg("Schema DATA too big", *argv);
memcpy(opts.sc_data, *argv, strlen(*argv));
opts.cmd = IOAM6_CMD_ADD_SCHEMA;
} else if (strcmp(*argv, "del") == 0) {
NEXT_ARG();
if (get_u32(&opts.sc_id, *argv, 0))
invarg("Invalid schema ID", *argv);
opts.cmd = IOAM6_CMD_DEL_SCHEMA;
} else {
invarg("Unknown", *argv);
}
} else {
invarg("Unknown", *argv);
}
return ioam6_do_cmd();
}

View File

@ -50,21 +50,20 @@ void iplink_types_usage(void)
{ {
/* Remember to add new entry here if new type is added. */ /* Remember to add new entry here if new type is added. */
fprintf(stderr, fprintf(stderr,
"TYPE := { amt | bareudp | bond | bond_slave | bridge | bridge_slave |\n" "TYPE := { bareudp | bond | bond_slave | bridge | bridge_slave |\n"
" dummy | erspan | geneve | gre | gretap | ifb |\n" " dummy | erspan | geneve | gre | gretap | ifb |\n"
" ip6erspan | ip6gre | ip6gretap | ip6tnl |\n" " ip6erspan | ip6gre | ip6gretap | ip6tnl |\n"
" ipip | ipoib | ipvlan | ipvtap |\n" " ipip | ipoib | ipvlan | ipvtap |\n"
" macsec | macvlan | macvtap |\n" " macsec | macvlan | macvtap |\n"
" netdevsim | nlmon | rmnet | sit | team | team_slave |\n" " netdevsim | nlmon | rmnet | sit | team | team_slave |\n"
" vcan | veth | vlan | vrf | vti | vxcan | vxlan | wwan |\n" " vcan | veth | vlan | vrf | vti | vxcan | vxlan | xfrm }\n");
" xfrm }\n");
} }
void iplink_usage(void) void iplink_usage(void)
{ {
if (iplink_have_newlink()) { if (iplink_have_newlink()) {
fprintf(stderr, fprintf(stderr,
"Usage: ip link add [link DEV | parentdev NAME] [ name ] NAME\n" "Usage: ip link add [link DEV] [ name ] NAME\n"
" [ txqueuelen PACKETS ]\n" " [ txqueuelen PACKETS ]\n"
" [ address LLADDR ]\n" " [ address LLADDR ]\n"
" [ broadcast LLADDR ]\n" " [ broadcast LLADDR ]\n"
@ -120,7 +119,6 @@ void iplink_usage(void)
" [ gso_max_size BYTES ] | [ gso_max_segs PACKETS ]\n" " [ gso_max_size BYTES ] | [ gso_max_segs PACKETS ]\n"
"\n" "\n"
" ip link show [ DEVICE | group GROUP ] [up] [master DEV] [vrf NAME] [type TYPE]\n" " ip link show [ DEVICE | group GROUP ] [up] [master DEV] [vrf NAME] [type TYPE]\n"
" [nomaster]\n"
"\n" "\n"
" ip link xstats type TYPE [ ARGS ]\n" " ip link xstats type TYPE [ ARGS ]\n"
"\n" "\n"
@ -579,7 +577,6 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
{ {
bool move_netns = false;
char *name = NULL; char *name = NULL;
char *dev = NULL; char *dev = NULL;
char *link = NULL; char *link = NULL;
@ -685,7 +682,6 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
IFLA_NET_NS_PID, &netns, 4); IFLA_NET_NS_PID, &netns, 4);
else else
invarg("Invalid \"netns\" value\n", *argv); invarg("Invalid \"netns\" value\n", *argv);
move_netns = true;
} else if (strcmp(*argv, "multicast") == 0) { } else if (strcmp(*argv, "multicast") == 0) {
NEXT_ARG(); NEXT_ARG();
req->i.ifi_change |= IFF_MULTICAST; req->i.ifi_change |= IFF_MULTICAST;
@ -942,10 +938,6 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
*argv); *argv);
addattr32(&req->n, sizeof(*req), addattr32(&req->n, sizeof(*req),
IFLA_GSO_MAX_SEGS, max_segs); IFLA_GSO_MAX_SEGS, max_segs);
} else if (strcmp(*argv, "parentdev") == 0) {
NEXT_ARG();
addattr_l(&req->n, sizeof(*req), IFLA_PARENT_DEV_NAME,
*argv, strlen(*argv) + 1);
} else { } else {
if (matches(*argv, "help") == 0) if (matches(*argv, "help") == 0)
usage(); usage();
@ -983,11 +975,9 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
} }
} }
if (index && if (!(req->n.nlmsg_flags & NLM_F_CREATE) && index) {
(!(req->n.nlmsg_flags & NLM_F_CREATE) &&
!move_netns)) {
fprintf(stderr, fprintf(stderr,
"index can be used only when creating devices or when moving device to another netns.\n"); "index can be used only when creating devices.\n");
exit(-1); exit(-1);
} }
@ -1024,9 +1014,6 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
/* Not renaming to the same name */ /* Not renaming to the same name */
if (name == dev) if (name == dev)
name = NULL; name = NULL;
if (index)
addattr32(&req->n, sizeof(*req), IFLA_NEW_IFINDEX, index);
} else { } else {
if (name != dev) { if (name != dev) {
fprintf(stderr, fprintf(stderr,

View File

@ -1,200 +0,0 @@
/*
* iplink_amt.c AMT device support
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* Authors: Taehee Yoo <ap420073@gmail.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <net/if.h>
#include <linux/ip.h>
#include <linux/if_link.h>
#include <arpa/inet.h>
#include <linux/amt.h>
#include "rt_names.h"
#include "utils.h"
#include "ip_common.h"
#define AMT_ATTRSET(attrs, type) (((attrs) & (1L << (type))) != 0)
static void print_usage(FILE *f)
{
fprintf(f,
"Usage: ... amt\n"
" [ discovery IP_ADDRESS ]\n"
" [ mode MODE ]\n"
" [ local ADDR ]\n"
" [ dev PHYS_DEV ]\n"
" [ relay_port PORT ]\n"
" [ gateway_port PORT ]\n"
" [ max_tunnels NUMBER ]\n"
"\n"
"Where: ADDR := { IP_ADDRESS }\n"
" MODE := { gateway | relay }\n"
);
}
static char *modename[] = {"gateway", "relay"};
static void usage(void)
{
print_usage(stderr);
}
static void check_duparg(__u64 *attrs, int type, const char *key,
const char *argv)
{
if (!AMT_ATTRSET(*attrs, type)) {
*attrs |= (1L << type);
return;
}
duparg2(key, argv);
}
static int amt_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
unsigned int mode, max_tunnels;
inet_prefix saddr, daddr;
__u64 attrs = 0;
__u16 port;
saddr.family = daddr.family = AF_UNSPEC;
inet_prefix_reset(&saddr);
inet_prefix_reset(&daddr);
while (argc > 0) {
if (strcmp(*argv, "mode") == 0) {
NEXT_ARG();
if (strcmp(*argv, "gateway") == 0) {
mode = 0;
} else if (strcmp(*argv, "relay") == 0) {
mode = 1;
} else {
usage();
return -1;
}
addattr32(n, 1024, IFLA_AMT_MODE, mode);
} else if (strcmp(*argv, "relay_port") == 0) {
NEXT_ARG();
if (get_u16(&port, *argv, 0))
invarg("relay_port", *argv);
addattr16(n, 1024, IFLA_AMT_RELAY_PORT, htons(port));
} else if (strcmp(*argv, "gateway_port") == 0) {
NEXT_ARG();
if (get_u16(&port, *argv, 0))
invarg("gateway_port", *argv);
addattr16(n, 1024, IFLA_AMT_GATEWAY_PORT, htons(port));
} else if (strcmp(*argv, "max_tunnels") == 0) {
NEXT_ARG();
if (get_u32(&max_tunnels, *argv, 0))
invarg("max_tunnels", *argv);
addattr32(n, 1024, IFLA_AMT_MAX_TUNNELS, max_tunnels);
} else if (strcmp(*argv, "dev") == 0) {
unsigned int link;
NEXT_ARG();
link = ll_name_to_index(*argv);
if (!link)
exit(nodev(*argv));
addattr32(n, 1024, IFLA_AMT_LINK, link);
} else if (strcmp(*argv, "local") == 0) {
NEXT_ARG();
check_duparg(&attrs, IFLA_AMT_LOCAL_IP, "local", *argv);
get_addr(&saddr, *argv, daddr.family);
if (is_addrtype_inet(&saddr))
addattr_l(n, 1024, IFLA_AMT_LOCAL_IP,
saddr.data, saddr.bytelen);
} else if (strcmp(*argv, "discovery") == 0) {
NEXT_ARG();
check_duparg(&attrs, IFLA_AMT_DISCOVERY_IP,
"discovery", *argv);
get_addr(&daddr, *argv, daddr.family);
if (is_addrtype_inet(&daddr))
addattr_l(n, 1024, IFLA_AMT_DISCOVERY_IP,
daddr.data, daddr.bytelen);
} else if (strcmp(*argv, "help") == 0) {
usage();
return -1;
} else {
fprintf(stderr, "amt: unknown command \"%s\"?\n", *argv);
usage();
return -1;
}
argc--, argv++;
}
return 0;
}
static void amt_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
if (!tb)
return;
if (tb[IFLA_AMT_MODE])
print_string(PRINT_ANY, "mode", "%s ",
modename[rta_getattr_u32(tb[IFLA_AMT_MODE])]);
if (tb[IFLA_AMT_GATEWAY_PORT])
print_uint(PRINT_ANY, "gateway_port", "gateway_port %u ",
rta_getattr_be16(tb[IFLA_AMT_GATEWAY_PORT]));
if (tb[IFLA_AMT_RELAY_PORT])
print_uint(PRINT_ANY, "relay_port", "relay_port %u ",
rta_getattr_be16(tb[IFLA_AMT_RELAY_PORT]));
if (tb[IFLA_AMT_LOCAL_IP]) {
__be32 addr = rta_getattr_u32(tb[IFLA_AMT_LOCAL_IP]);
print_string(PRINT_ANY, "local", "local %s ",
format_host(AF_INET, 4, &addr));
}
if (tb[IFLA_AMT_REMOTE_IP]) {
__be32 addr = rta_getattr_u32(tb[IFLA_AMT_REMOTE_IP]);
print_string(PRINT_ANY, "remote", "remote %s ",
format_host(AF_INET, 4, &addr));
}
if (tb[IFLA_AMT_DISCOVERY_IP]) {
__be32 addr = rta_getattr_u32(tb[IFLA_AMT_DISCOVERY_IP]);
print_string(PRINT_ANY, "discovery", "discovery %s ",
format_host(AF_INET, 4, &addr));
}
if (tb[IFLA_AMT_LINK]) {
unsigned int link = rta_getattr_u32(tb[IFLA_AMT_LINK]);
print_string(PRINT_ANY, "link", "dev %s ",
ll_index_to_name(link));
}
if (tb[IFLA_AMT_MAX_TUNNELS])
print_uint(PRINT_ANY, "max_tunnels", "max_tunnels %u ",
rta_getattr_u32(tb[IFLA_AMT_MAX_TUNNELS]));
}
static void amt_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
{
print_usage(f);
}
struct link_util amt_link_util = {
.id = "amt",
.maxattr = IFLA_AMT_MAX,
.parse_opt = amt_parse_opt,
.print_opt = amt_print_opt,
.print_help = amt_print_help,
};

View File

@ -41,9 +41,6 @@ static const char *arp_validate_tbl[] = {
"active", "active",
"backup", "backup",
"all", "all",
"filter",
"filter_active",
"filter_backup",
NULL, NULL,
}; };
@ -77,12 +74,6 @@ static const char *xmit_hash_policy_tbl[] = {
NULL, NULL,
}; };
static const char *lacp_active_tbl[] = {
"off",
"on",
NULL,
};
static const char *lacp_rate_tbl[] = { static const char *lacp_rate_tbl[] = {
"slow", "slow",
"fast", "fast",
@ -148,19 +139,17 @@ static void print_explain(FILE *f)
" [ packets_per_slave PACKETS_PER_SLAVE ]\n" " [ packets_per_slave PACKETS_PER_SLAVE ]\n"
" [ tlb_dynamic_lb TLB_DYNAMIC_LB ]\n" " [ tlb_dynamic_lb TLB_DYNAMIC_LB ]\n"
" [ lacp_rate LACP_RATE ]\n" " [ lacp_rate LACP_RATE ]\n"
" [ lacp_active LACP_ACTIVE]\n"
" [ ad_select AD_SELECT ]\n" " [ ad_select AD_SELECT ]\n"
" [ ad_user_port_key PORTKEY ]\n" " [ ad_user_port_key PORTKEY ]\n"
" [ ad_actor_sys_prio SYSPRIO ]\n" " [ ad_actor_sys_prio SYSPRIO ]\n"
" [ ad_actor_system LLADDR ]\n" " [ ad_actor_system LLADDR ]\n"
"\n" "\n"
"BONDMODE := balance-rr|active-backup|balance-xor|broadcast|802.3ad|balance-tlb|balance-alb\n" "BONDMODE := balance-rr|active-backup|balance-xor|broadcast|802.3ad|balance-tlb|balance-alb\n"
"ARP_VALIDATE := none|active|backup|all|filter|filter_active|filter_backup\n" "ARP_VALIDATE := none|active|backup|all\n"
"ARP_ALL_TARGETS := any|all\n" "ARP_ALL_TARGETS := any|all\n"
"PRIMARY_RESELECT := always|better|failure\n" "PRIMARY_RESELECT := always|better|failure\n"
"FAIL_OVER_MAC := none|active|follow\n" "FAIL_OVER_MAC := none|active|follow\n"
"XMIT_HASH_POLICY := layer2|layer2+3|layer3+4|encap2+3|encap3+4|vlan+srcmac\n" "XMIT_HASH_POLICY := layer2|layer2+3|layer3+4|encap2+3|encap3+4|vlan+srcmac\n"
"LACP_ACTIVE := off|on\n"
"LACP_RATE := slow|fast\n" "LACP_RATE := slow|fast\n"
"AD_SELECT := stable|bandwidth|count\n" "AD_SELECT := stable|bandwidth|count\n"
); );
@ -176,7 +165,7 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
{ {
__u8 mode, use_carrier, primary_reselect, fail_over_mac; __u8 mode, use_carrier, primary_reselect, fail_over_mac;
__u8 xmit_hash_policy, num_peer_notif, all_slaves_active; __u8 xmit_hash_policy, num_peer_notif, all_slaves_active;
__u8 lacp_active, lacp_rate, ad_select, tlb_dynamic_lb; __u8 lacp_rate, ad_select, tlb_dynamic_lb;
__u16 ad_user_port_key, ad_actor_sys_prio; __u16 ad_user_port_key, ad_actor_sys_prio;
__u32 miimon, updelay, downdelay, peer_notify_delay, arp_interval, arp_validate; __u32 miimon, updelay, downdelay, peer_notify_delay, arp_interval, arp_validate;
__u32 arp_all_targets, resend_igmp, min_links, lp_interval; __u32 arp_all_targets, resend_igmp, min_links, lp_interval;
@ -334,13 +323,6 @@ static int bond_parse_opt(struct link_util *lu, int argc, char **argv,
lacp_rate = get_index(lacp_rate_tbl, *argv); lacp_rate = get_index(lacp_rate_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_AD_LACP_RATE, lacp_rate); addattr8(n, 1024, IFLA_BOND_AD_LACP_RATE, lacp_rate);
} else if (strcmp(*argv, "lacp_active") == 0) {
NEXT_ARG();
if (get_index(lacp_active_tbl, *argv) < 0)
invarg("invalid lacp_active", *argv);
lacp_active = get_index(lacp_active_tbl, *argv);
addattr8(n, 1024, IFLA_BOND_AD_LACP_ACTIVE, lacp_active);
} else if (matches(*argv, "ad_select") == 0) { } else if (matches(*argv, "ad_select") == 0) {
NEXT_ARG(); NEXT_ARG();
if (get_index(ad_select_tbl, *argv) < 0) if (get_index(ad_select_tbl, *argv) < 0)
@ -579,15 +561,6 @@ static void bond_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
"packets_per_slave %u ", "packets_per_slave %u ",
rta_getattr_u32(tb[IFLA_BOND_PACKETS_PER_SLAVE])); rta_getattr_u32(tb[IFLA_BOND_PACKETS_PER_SLAVE]));
if (tb[IFLA_BOND_AD_LACP_ACTIVE]) {
const char *lacp_active = get_name(lacp_active_tbl,
rta_getattr_u8(tb[IFLA_BOND_AD_LACP_ACTIVE]));
print_string(PRINT_ANY,
"ad_lacp_active",
"lacp_active %s ",
lacp_active);
}
if (tb[IFLA_BOND_AD_LACP_RATE]) { if (tb[IFLA_BOND_AD_LACP_RATE]) {
const char *lacp_rate = get_name(lacp_rate_tbl, const char *lacp_rate = get_name(lacp_rate_tbl,
rta_getattr_u8(tb[IFLA_BOND_AD_LACP_RATE])); rta_getattr_u8(tb[IFLA_BOND_AD_LACP_RATE]));

View File

@ -43,7 +43,6 @@ static void print_explain(FILE *f)
" [ vlan_stats_enabled VLAN_STATS_ENABLED ]\n" " [ vlan_stats_enabled VLAN_STATS_ENABLED ]\n"
" [ vlan_stats_per_port VLAN_STATS_PER_PORT ]\n" " [ vlan_stats_per_port VLAN_STATS_PER_PORT ]\n"
" [ mcast_snooping MULTICAST_SNOOPING ]\n" " [ mcast_snooping MULTICAST_SNOOPING ]\n"
" [ mcast_vlan_snooping MULTICAST_VLAN_SNOOPING ]\n"
" [ mcast_router MULTICAST_ROUTER ]\n" " [ mcast_router MULTICAST_ROUTER ]\n"
" [ mcast_query_use_ifaddr MCAST_QUERY_USE_IFADDR ]\n" " [ mcast_query_use_ifaddr MCAST_QUERY_USE_IFADDR ]\n"
" [ mcast_querier MULTICAST_QUERIER ]\n" " [ mcast_querier MULTICAST_QUERIER ]\n"
@ -84,7 +83,6 @@ void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len)
static int bridge_parse_opt(struct link_util *lu, int argc, char **argv, static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n) struct nlmsghdr *n)
{ {
struct br_boolopt_multi bm = {};
__u32 val; __u32 val;
while (argc > 0) { while (argc > 0) {
@ -202,18 +200,6 @@ static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
invarg("invalid mcast_snooping", *argv); invarg("invalid mcast_snooping", *argv);
addattr8(n, 1024, IFLA_BR_MCAST_SNOOPING, mcast_snoop); addattr8(n, 1024, IFLA_BR_MCAST_SNOOPING, mcast_snoop);
} else if (strcmp(*argv, "mcast_vlan_snooping") == 0) {
__u32 mcvl_bit = 1 << BR_BOOLOPT_MCAST_VLAN_SNOOPING;
__u8 mcast_vlan_snooping;
NEXT_ARG();
if (get_u8(&mcast_vlan_snooping, *argv, 0))
invarg("invalid mcast_vlan_snooping", *argv);
bm.optmask |= 1 << BR_BOOLOPT_MCAST_VLAN_SNOOPING;
if (mcast_vlan_snooping)
bm.optval |= mcvl_bit;
else
bm.optval &= ~mcvl_bit;
} else if (matches(*argv, "mcast_query_use_ifaddr") == 0) { } else if (matches(*argv, "mcast_query_use_ifaddr") == 0) {
__u8 mcast_qui; __u8 mcast_qui;
@ -393,9 +379,6 @@ static int bridge_parse_opt(struct link_util *lu, int argc, char **argv,
argc--, argv++; argc--, argv++;
} }
if (bm.optmask)
addattr_l(n, 1024, IFLA_BR_MULTI_BOOLOPT,
&bm, sizeof(bm));
return 0; return 0;
} }
@ -576,18 +559,6 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
"mcast_snooping %u ", "mcast_snooping %u ",
rta_getattr_u8(tb[IFLA_BR_MCAST_SNOOPING])); rta_getattr_u8(tb[IFLA_BR_MCAST_SNOOPING]));
if (tb[IFLA_BR_MULTI_BOOLOPT]) {
__u32 mcvl_bit = 1 << BR_BOOLOPT_MCAST_VLAN_SNOOPING;
struct br_boolopt_multi *bm;
bm = RTA_DATA(tb[IFLA_BR_MULTI_BOOLOPT]);
if (bm->optmask & mcvl_bit)
print_uint(PRINT_ANY,
"mcast_vlan_snooping",
"mcast_vlan_snooping %u ",
!!(bm->optval & mcvl_bit));
}
if (tb[IFLA_BR_MCAST_ROUTER]) if (tb[IFLA_BR_MCAST_ROUTER])
print_uint(PRINT_ANY, print_uint(PRINT_ANY,
"mcast_router", "mcast_router",

View File

@ -28,7 +28,6 @@ static void print_usage(FILE *f)
"\n" "\n"
"\t[ dbitrate BITRATE [ dsample-point SAMPLE-POINT] ] |\n" "\t[ dbitrate BITRATE [ dsample-point SAMPLE-POINT] ] |\n"
"\t[ dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1\n \t dphase-seg2 PHASE-SEG2 [ dsjw SJW ] ]\n" "\t[ dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1\n \t dphase-seg2 PHASE-SEG2 [ dsjw SJW ] ]\n"
"\t[ tdcv TDCV tdco TDCO tdcf TDCF ]\n"
"\n" "\n"
"\t[ loopback { on | off } ]\n" "\t[ loopback { on | off } ]\n"
"\t[ listen-only { on | off } ]\n" "\t[ listen-only { on | off } ]\n"
@ -39,24 +38,20 @@ static void print_usage(FILE *f)
"\t[ fd-non-iso { on | off } ]\n" "\t[ fd-non-iso { on | off } ]\n"
"\t[ presume-ack { on | off } ]\n" "\t[ presume-ack { on | off } ]\n"
"\t[ cc-len8-dlc { on | off } ]\n" "\t[ cc-len8-dlc { on | off } ]\n"
"\t[ tdc-mode { auto | manual | off } ]\n"
"\n" "\n"
"\t[ restart-ms TIME-MS ]\n" "\t[ restart-ms TIME-MS ]\n"
"\t[ restart ]\n" "\t[ restart ]\n"
"\n" "\n"
"\t[ termination { 0..65535 } ]\n" "\t[ termination { 0..65535 } ]\n"
"\n" "\n"
"\tWhere: BITRATE := { NUMBER in bps }\n" "\tWhere: BITRATE := { 1..1000000 }\n"
"\t SAMPLE-POINT := { 0.000..0.999 }\n" "\t SAMPLE-POINT := { 0.000..0.999 }\n"
"\t TQ := { NUMBER in ns }\n" "\t TQ := { NUMBER }\n"
"\t PROP-SEG := { NUMBER in tq }\n" "\t PROP-SEG := { 1..8 }\n"
"\t PHASE-SEG1 := { NUMBER in tq }\n" "\t PHASE-SEG1 := { 1..8 }\n"
"\t PHASE-SEG2 := { NUMBER in tq }\n" "\t PHASE-SEG2 := { 1..8 }\n"
"\t SJW := { NUMBER in tq }\n" "\t SJW := { 1..4 }\n"
"\t TDCV := { NUMBER in tc}\n" "\t RESTART-MS := { 0 | NUMBER }\n"
"\t TDCO := { NUMBER in tc}\n"
"\t TDCF := { NUMBER in tc}\n"
"\t RESTART-MS := { 0 | NUMBER in ms }\n"
); );
} }
@ -93,47 +88,34 @@ static void set_ctrlmode(char *name, char *arg,
cm->mask |= flags; cm->mask |= flags;
} }
static void print_flag(enum output_type t, __u32 *flags, __u32 flag, static void print_ctrlmode(FILE *f, __u32 cm)
const char* name)
{ {
if (*flags & flag) { open_json_array(PRINT_ANY, is_json_context() ? "ctrlmode" : "<");
*flags &= ~flag; #define _PF(cmflag, cmname) \
print_string(t, NULL, *flags ? "%s," : "%s", name); if (cm & cmflag) { \
cm &= ~cmflag; \
print_string(PRINT_ANY, NULL, cm ? "%s," : "%s", cmname); \
} }
} _PF(CAN_CTRLMODE_LOOPBACK, "LOOPBACK");
_PF(CAN_CTRLMODE_LISTENONLY, "LISTEN-ONLY");
static void print_ctrlmode(enum output_type t, __u32 flags, const char* key) _PF(CAN_CTRLMODE_3_SAMPLES, "TRIPLE-SAMPLING");
{ _PF(CAN_CTRLMODE_ONE_SHOT, "ONE-SHOT");
if (!flags) _PF(CAN_CTRLMODE_BERR_REPORTING, "BERR-REPORTING");
return; _PF(CAN_CTRLMODE_FD, "FD");
_PF(CAN_CTRLMODE_FD_NON_ISO, "FD-NON-ISO");
open_json_array(t, is_json_context() ? key : "<"); _PF(CAN_CTRLMODE_PRESUME_ACK, "PRESUME-ACK");
_PF(CAN_CTRLMODE_CC_LEN8_DLC, "CC-LEN8-DLC");
print_flag(t, &flags, CAN_CTRLMODE_LOOPBACK, "LOOPBACK"); #undef _PF
print_flag(t, &flags, CAN_CTRLMODE_LISTENONLY, "LISTEN-ONLY"); if (cm)
print_flag(t, &flags, CAN_CTRLMODE_3_SAMPLES, "TRIPLE-SAMPLING"); print_hex(PRINT_ANY, NULL, "%x", cm);
print_flag(t, &flags, CAN_CTRLMODE_ONE_SHOT, "ONE-SHOT"); close_json_array(PRINT_ANY, "> ");
print_flag(t, &flags, CAN_CTRLMODE_BERR_REPORTING, "BERR-REPORTING");
print_flag(t, &flags, CAN_CTRLMODE_FD, "FD");
print_flag(t, &flags, CAN_CTRLMODE_FD_NON_ISO, "FD-NON-ISO");
print_flag(t, &flags, CAN_CTRLMODE_PRESUME_ACK, "PRESUME-ACK");
print_flag(t, &flags, CAN_CTRLMODE_CC_LEN8_DLC, "CC-LEN8-DLC");
print_flag(t, &flags, CAN_CTRLMODE_TDC_AUTO, "TDC-AUTO");
print_flag(t, &flags, CAN_CTRLMODE_TDC_MANUAL, "TDC-MANUAL");
if (flags)
print_hex(t, NULL, "%x", flags);
close_json_array(t, "> ");
} }
static int can_parse_opt(struct link_util *lu, int argc, char **argv, static int can_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n) struct nlmsghdr *n)
{ {
struct can_bittiming bt = {}, dbt = {}; struct can_bittiming bt = {}, dbt = {};
struct can_ctrlmode cm = { 0 }; struct can_ctrlmode cm = {0, 0};
struct rtattr *tdc;
__u32 tdcv = -1, tdco = -1, tdcf = -1;
while (argc > 0) { while (argc > 0) {
if (matches(*argv, "bitrate") == 0) { if (matches(*argv, "bitrate") == 0) {
@ -199,18 +181,6 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
NEXT_ARG(); NEXT_ARG();
if (get_u32(&dbt.sjw, *argv, 0)) if (get_u32(&dbt.sjw, *argv, 0))
invarg("invalid \"dsjw\" value\n", *argv); invarg("invalid \"dsjw\" value\n", *argv);
} else if (matches(*argv, "tdcv") == 0) {
NEXT_ARG();
if (get_u32(&tdcv, *argv, 0))
invarg("invalid \"tdcv\" value\n", *argv);
} else if (matches(*argv, "tdco") == 0) {
NEXT_ARG();
if (get_u32(&tdco, *argv, 0))
invarg("invalid \"tdco\" value\n", *argv);
} else if (matches(*argv, "tdcf") == 0) {
NEXT_ARG();
if (get_u32(&tdcf, *argv, 0))
invarg("invalid \"tdcf\" value\n", *argv);
} else if (matches(*argv, "loopback") == 0) { } else if (matches(*argv, "loopback") == 0) {
NEXT_ARG(); NEXT_ARG();
set_ctrlmode("loopback", *argv, &cm, set_ctrlmode("loopback", *argv, &cm,
@ -247,23 +217,6 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
NEXT_ARG(); NEXT_ARG();
set_ctrlmode("cc-len8-dlc", *argv, &cm, set_ctrlmode("cc-len8-dlc", *argv, &cm,
CAN_CTRLMODE_CC_LEN8_DLC); CAN_CTRLMODE_CC_LEN8_DLC);
} else if (matches(*argv, "tdc-mode") == 0) {
NEXT_ARG();
if (strcmp(*argv, "auto") == 0) {
cm.flags |= CAN_CTRLMODE_TDC_AUTO;
cm.mask |= CAN_CTRLMODE_TDC_AUTO;
} else if (strcmp(*argv, "manual") == 0) {
cm.flags |= CAN_CTRLMODE_TDC_MANUAL;
cm.mask |= CAN_CTRLMODE_TDC_MANUAL;
} else if (strcmp(*argv, "off") == 0) {
cm.mask |= CAN_CTRLMODE_TDC_AUTO |
CAN_CTRLMODE_TDC_MANUAL;
} else {
fprintf(stderr,
"Error: argument of \"tdc-mode\" must be \"auto\", \"manual\" or \"off\", not \"%s\"\n",
*argv);
exit (-1);
}
} else if (matches(*argv, "restart") == 0) { } else if (matches(*argv, "restart") == 0) {
__u32 val = 1; __u32 val = 1;
@ -301,17 +254,6 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,
if (cm.mask) if (cm.mask)
addattr_l(n, 1024, IFLA_CAN_CTRLMODE, &cm, sizeof(cm)); addattr_l(n, 1024, IFLA_CAN_CTRLMODE, &cm, sizeof(cm));
if (tdcv != -1 || tdco != -1 || tdcf != -1) {
tdc = addattr_nest(n, 1024, IFLA_CAN_TDC | NLA_F_NESTED);
if (tdcv != -1)
addattr32(n, 1024, IFLA_CAN_TDC_TDCV, tdcv);
if (tdco != -1)
addattr32(n, 1024, IFLA_CAN_TDC_TDCO, tdco);
if (tdcf != -1)
addattr32(n, 1024, IFLA_CAN_TDC_TDCF, tdcf);
addattr_nest_end(n, tdc);
}
return 0; return 0;
} }
@ -324,75 +266,11 @@ static const char *can_state_names[CAN_STATE_MAX] = {
[CAN_STATE_SLEEPING] = "SLEEPING" [CAN_STATE_SLEEPING] = "SLEEPING"
}; };
static void can_print_nl_indent(void) static void can_print_json_timing_min_max(const char *attr, int min, int max)
{ {
print_nl(); open_json_object(attr);
print_string(PRINT_FP, NULL, "%s", "\t "); print_int(PRINT_JSON, "min", NULL, min);
} print_int(PRINT_JSON, "max", NULL, max);
static void can_print_timing_min_max(const char *json_attr, const char *fp_attr,
int min, int max)
{
print_null(PRINT_FP, NULL, fp_attr, NULL);
open_json_object(json_attr);
print_uint(PRINT_ANY, "min", " %d", min);
print_uint(PRINT_ANY, "max", "..%d", max);
close_json_object();
}
static void can_print_tdc_opt(FILE *f, struct rtattr *tdc_attr)
{
struct rtattr *tb[IFLA_CAN_TDC_MAX + 1];
parse_rtattr_nested(tb, IFLA_CAN_TDC_MAX, tdc_attr);
if (tb[IFLA_CAN_TDC_TDCV] || tb[IFLA_CAN_TDC_TDCO] ||
tb[IFLA_CAN_TDC_TDCF]) {
open_json_object("tdc");
can_print_nl_indent();
if (tb[IFLA_CAN_TDC_TDCV]) {
__u32 *tdcv = RTA_DATA(tb[IFLA_CAN_TDC_TDCV]);
print_uint(PRINT_ANY, "tdcv", " tdcv %u", *tdcv);
}
if (tb[IFLA_CAN_TDC_TDCO]) {
__u32 *tdco = RTA_DATA(tb[IFLA_CAN_TDC_TDCO]);
print_uint(PRINT_ANY, "tdco", " tdco %u", *tdco);
}
if (tb[IFLA_CAN_TDC_TDCF]) {
__u32 *tdcf = RTA_DATA(tb[IFLA_CAN_TDC_TDCF]);
print_uint(PRINT_ANY, "tdcf", " tdcf %u", *tdcf);
}
close_json_object();
}
}
static void can_print_tdc_const_opt(FILE *f, struct rtattr *tdc_attr)
{
struct rtattr *tb[IFLA_CAN_TDC_MAX + 1];
parse_rtattr_nested(tb, IFLA_CAN_TDC_MAX, tdc_attr);
open_json_object("tdc");
can_print_nl_indent();
if (tb[IFLA_CAN_TDC_TDCV_MIN] && tb[IFLA_CAN_TDC_TDCV_MAX]) {
__u32 *tdcv_min = RTA_DATA(tb[IFLA_CAN_TDC_TDCV_MIN]);
__u32 *tdcv_max = RTA_DATA(tb[IFLA_CAN_TDC_TDCV_MAX]);
can_print_timing_min_max("tdcv", " tdcv", *tdcv_min, *tdcv_max);
}
if (tb[IFLA_CAN_TDC_TDCO_MIN] && tb[IFLA_CAN_TDC_TDCO_MAX]) {
__u32 *tdco_min = RTA_DATA(tb[IFLA_CAN_TDC_TDCO_MIN]);
__u32 *tdco_max = RTA_DATA(tb[IFLA_CAN_TDC_TDCO_MAX]);
can_print_timing_min_max("tdco", " tdco", *tdco_min, *tdco_max);
}
if (tb[IFLA_CAN_TDC_TDCF_MIN] && tb[IFLA_CAN_TDC_TDCF_MAX]) {
__u32 *tdcf_min = RTA_DATA(tb[IFLA_CAN_TDC_TDCF_MIN]);
__u32 *tdcf_max = RTA_DATA(tb[IFLA_CAN_TDC_TDCF_MAX]);
can_print_timing_min_max("tdcf", " tdcf", *tdcf_min, *tdcf_max);
}
close_json_object(); close_json_object();
} }
@ -404,7 +282,8 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (tb[IFLA_CAN_CTRLMODE]) { if (tb[IFLA_CAN_CTRLMODE]) {
struct can_ctrlmode *cm = RTA_DATA(tb[IFLA_CAN_CTRLMODE]); struct can_ctrlmode *cm = RTA_DATA(tb[IFLA_CAN_CTRLMODE]);
print_ctrlmode(PRINT_ANY, cm->flags, "ctrlmode"); if (cm->flags)
print_ctrlmode(f, cm->flags);
} }
if (tb[IFLA_CAN_STATE]) { if (tb[IFLA_CAN_STATE]) {
@ -418,39 +297,56 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
struct can_berr_counter *bc = struct can_berr_counter *bc =
RTA_DATA(tb[IFLA_CAN_BERR_COUNTER]); RTA_DATA(tb[IFLA_CAN_BERR_COUNTER]);
open_json_object("berr_counter"); if (is_json_context()) {
print_uint(PRINT_ANY, "tx", "(berr-counter tx %u", bc->txerr); open_json_object("berr_counter");
print_uint(PRINT_ANY, "rx", " rx %u) ", bc->rxerr); print_int(PRINT_JSON, "tx", NULL, bc->txerr);
close_json_object(); print_int(PRINT_JSON, "rx", NULL, bc->rxerr);
close_json_object();
} else {
fprintf(f, "(berr-counter tx %d rx %d) ",
bc->txerr, bc->rxerr);
}
} }
if (tb[IFLA_CAN_RESTART_MS]) { if (tb[IFLA_CAN_RESTART_MS]) {
__u32 *restart_ms = RTA_DATA(tb[IFLA_CAN_RESTART_MS]); __u32 *restart_ms = RTA_DATA(tb[IFLA_CAN_RESTART_MS]);
print_uint(PRINT_ANY, "restart_ms", "restart-ms %u ", print_int(PRINT_ANY,
*restart_ms); "restart_ms",
"restart-ms %d ",
*restart_ms);
} }
/* bittiming is irrelevant if fixed bitrate is defined */ /* bittiming is irrelevant if fixed bitrate is defined */
if (tb[IFLA_CAN_BITTIMING] && !tb[IFLA_CAN_BITRATE_CONST]) { if (tb[IFLA_CAN_BITTIMING] && !tb[IFLA_CAN_BITRATE_CONST]) {
struct can_bittiming *bt = RTA_DATA(tb[IFLA_CAN_BITTIMING]); struct can_bittiming *bt = RTA_DATA(tb[IFLA_CAN_BITTIMING]);
char sp[6];
open_json_object("bittiming"); if (is_json_context()) {
can_print_nl_indent(); json_writer_t *jw;
print_uint(PRINT_ANY, "bitrate", " bitrate %u", bt->bitrate);
snprintf(sp, sizeof(sp), "%.3f", bt->sample_point / 1000.); open_json_object("bittiming");
print_string(PRINT_ANY, "sample_point", " sample-point %s", sp); print_int(PRINT_ANY, "bitrate", NULL, bt->bitrate);
can_print_nl_indent(); jw = get_json_writer();
print_uint(PRINT_ANY, "tq", " tq %u", bt->tq); jsonw_name(jw, "sample_point");
print_uint(PRINT_ANY, "prop_seg", " prop-seg %u", bt->prop_seg); jsonw_printf(jw, "%.3f",
print_uint(PRINT_ANY, "phase_seg1", " phase-seg1 %u", (float) bt->sample_point / 1000);
bt->phase_seg1); print_int(PRINT_ANY, "tq", NULL, bt->tq);
print_uint(PRINT_ANY, "phase_seg2", " phase-seg2 %u", print_int(PRINT_ANY, "prop_seg", NULL, bt->prop_seg);
bt->phase_seg2); print_int(PRINT_ANY, "phase_seg1",
print_uint(PRINT_ANY, "sjw", " sjw %u", bt->sjw); NULL, bt->phase_seg1);
print_uint(PRINT_ANY, "brp", " brp %u", bt->brp); print_int(PRINT_ANY, "phase_seg2",
close_json_object(); NULL, bt->phase_seg2);
print_int(PRINT_ANY, "sjw", NULL, bt->sjw);
close_json_object();
} else {
fprintf(f, "\n bitrate %d sample-point %.3f ",
bt->bitrate, (float) bt->sample_point / 1000.);
fprintf(f,
"\n tq %d prop-seg %d phase-seg1 %d phase-seg2 %d sjw %d",
bt->tq, bt->prop_seg,
bt->phase_seg1, bt->phase_seg2,
bt->sjw);
}
} }
/* bittiming const is irrelevant if fixed bitrate is defined */ /* bittiming const is irrelevant if fixed bitrate is defined */
@ -458,18 +354,28 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
struct can_bittiming_const *btc = struct can_bittiming_const *btc =
RTA_DATA(tb[IFLA_CAN_BITTIMING_CONST]); RTA_DATA(tb[IFLA_CAN_BITTIMING_CONST]);
open_json_object("bittiming_const"); if (is_json_context()) {
can_print_nl_indent(); open_json_object("bittiming_const");
print_string(PRINT_ANY, "name", " %s:", btc->name); print_string(PRINT_JSON, "name", NULL, btc->name);
can_print_timing_min_max("tseg1", " tseg1", can_print_json_timing_min_max("tseg1",
btc->tseg1_min, btc->tseg1_max); btc->tseg1_min,
can_print_timing_min_max("tseg2", " tseg2", btc->tseg1_max);
btc->tseg2_min, btc->tseg2_max); can_print_json_timing_min_max("tseg2",
can_print_timing_min_max("sjw", " sjw", 1, btc->sjw_max); btc->tseg2_min,
can_print_timing_min_max("brp", " brp", btc->tseg2_max);
btc->brp_min, btc->brp_max); can_print_json_timing_min_max("sjw", 1, btc->sjw_max);
print_uint(PRINT_ANY, "brp_inc", " brp_inc %u", btc->brp_inc); can_print_json_timing_min_max("brp",
close_json_object(); btc->brp_min,
btc->brp_max);
print_int(PRINT_JSON, "brp_inc", NULL, btc->brp_inc);
close_json_object();
} else {
fprintf(f, "\n %s: tseg1 %d..%d tseg2 %d..%d "
"sjw 1..%d brp %d..%d brp-inc %d",
btc->name, btc->tseg1_min, btc->tseg1_max,
btc->tseg2_min, btc->tseg2_max, btc->sjw_max,
btc->brp_min, btc->brp_max, btc->brp_inc);
}
} }
if (tb[IFLA_CAN_BITRATE_CONST]) { if (tb[IFLA_CAN_BITRATE_CONST]) {
@ -485,52 +391,64 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
bitrate = bt->bitrate; bitrate = bt->bitrate;
} }
can_print_nl_indent(); if (is_json_context()) {
print_uint(PRINT_ANY, "bittiming_bitrate", " bitrate %u", print_uint(PRINT_JSON,
bitrate); "bittiming_bitrate",
can_print_nl_indent(); NULL, bitrate);
open_json_array(PRINT_ANY, is_json_context() ? open_json_array(PRINT_JSON, "bitrate_const");
"bitrate_const" : " ["); for (i = 0; i < bitrate_cnt; ++i)
for (i = 0; i < bitrate_cnt; ++i) { print_uint(PRINT_JSON, NULL, NULL,
/* This will keep lines below 80 signs */ bitrate_const[i]);
if (!(i % 6) && i) { close_json_array(PRINT_JSON, NULL);
can_print_nl_indent(); } else {
print_string(PRINT_FP, NULL, "%s", " "); fprintf(f, "\n bitrate %u", bitrate);
fprintf(f, "\n [");
for (i = 0; i < bitrate_cnt - 1; ++i) {
/* This will keep lines below 80 signs */
if (!(i % 6) && i)
fprintf(f, "\n ");
fprintf(f, "%8u, ", bitrate_const[i]);
} }
print_uint(PRINT_ANY, NULL,
i < bitrate_cnt - 1 ? "%8u, " : "%8u", if (!(i % 6) && i)
bitrate_const[i]); fprintf(f, "\n ");
fprintf(f, "%8u ]", bitrate_const[i]);
} }
close_json_array(PRINT_JSON, " ]");
} }
/* data bittiming is irrelevant if fixed bitrate is defined */ /* data bittiming is irrelevant if fixed bitrate is defined */
if (tb[IFLA_CAN_DATA_BITTIMING] && !tb[IFLA_CAN_DATA_BITRATE_CONST]) { if (tb[IFLA_CAN_DATA_BITTIMING] && !tb[IFLA_CAN_DATA_BITRATE_CONST]) {
struct can_bittiming *dbt = struct can_bittiming *dbt =
RTA_DATA(tb[IFLA_CAN_DATA_BITTIMING]); RTA_DATA(tb[IFLA_CAN_DATA_BITTIMING]);
char dsp[6];
open_json_object("data_bittiming"); if (is_json_context()) {
can_print_nl_indent(); json_writer_t *jw;
print_uint(PRINT_ANY, "bitrate", " dbitrate %u", dbt->bitrate);
snprintf(dsp, sizeof(dsp), "%.3f", dbt->sample_point / 1000.);
print_string(PRINT_ANY, "sample_point", " dsample-point %s",
dsp);
can_print_nl_indent();
print_uint(PRINT_ANY, "tq", " dtq %u", dbt->tq);
print_uint(PRINT_ANY, "prop_seg", " dprop-seg %u",
dbt->prop_seg);
print_uint(PRINT_ANY, "phase_seg1", " dphase-seg1 %u",
dbt->phase_seg1);
print_uint(PRINT_ANY, "phase_seg2", " dphase-seg2 %u",
dbt->phase_seg2);
print_uint(PRINT_ANY, "sjw", " dsjw %u", dbt->sjw);
print_uint(PRINT_ANY, "brp", " dbrp %u", dbt->brp);
if (tb[IFLA_CAN_TDC]) open_json_object("data_bittiming");
can_print_tdc_opt(f, tb[IFLA_CAN_TDC]); print_int(PRINT_JSON, "bitrate", NULL, dbt->bitrate);
jw = get_json_writer();
close_json_object(); jsonw_name(jw, "sample_point");
jsonw_printf(jw, "%.3f",
(float) dbt->sample_point / 1000.);
print_int(PRINT_JSON, "tq", NULL, dbt->tq);
print_int(PRINT_JSON, "prop_seg", NULL, dbt->prop_seg);
print_int(PRINT_JSON, "phase_seg1",
NULL, dbt->phase_seg1);
print_int(PRINT_JSON, "phase_seg2",
NULL, dbt->phase_seg2);
print_int(PRINT_JSON, "sjw", NULL, dbt->sjw);
close_json_object();
} else {
fprintf(f, "\n dbitrate %d dsample-point %.3f ",
dbt->bitrate,
(float) dbt->sample_point / 1000.);
fprintf(f, "\n dtq %d dprop-seg %d dphase-seg1 %d "
"dphase-seg2 %d dsjw %d",
dbt->tq, dbt->prop_seg, dbt->phase_seg1,
dbt->phase_seg2, dbt->sjw);
}
} }
/* data bittiming const is irrelevant if fixed bitrate is defined */ /* data bittiming const is irrelevant if fixed bitrate is defined */
@ -539,22 +457,29 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
struct can_bittiming_const *dbtc = struct can_bittiming_const *dbtc =
RTA_DATA(tb[IFLA_CAN_DATA_BITTIMING_CONST]); RTA_DATA(tb[IFLA_CAN_DATA_BITTIMING_CONST]);
open_json_object("data_bittiming_const"); if (is_json_context()) {
can_print_nl_indent(); open_json_object("data_bittiming_const");
print_string(PRINT_ANY, "name", " %s:", dbtc->name); print_string(PRINT_JSON, "name", NULL, dbtc->name);
can_print_timing_min_max("tseg1", " dtseg1", can_print_json_timing_min_max("tseg1",
dbtc->tseg1_min, dbtc->tseg1_max); dbtc->tseg1_min,
can_print_timing_min_max("tseg2", " dtseg2", dbtc->tseg1_max);
dbtc->tseg2_min, dbtc->tseg2_max); can_print_json_timing_min_max("tseg2",
can_print_timing_min_max("sjw", " dsjw", 1, dbtc->sjw_max); dbtc->tseg2_min,
can_print_timing_min_max("brp", " dbrp", dbtc->tseg2_max);
dbtc->brp_min, dbtc->brp_max); can_print_json_timing_min_max("sjw", 1, dbtc->sjw_max);
print_uint(PRINT_ANY, "brp_inc", " dbrp_inc %u", dbtc->brp_inc); can_print_json_timing_min_max("brp",
dbtc->brp_min,
dbtc->brp_max);
if (tb[IFLA_CAN_TDC]) print_int(PRINT_JSON, "brp_inc", NULL, dbtc->brp_inc);
can_print_tdc_const_opt(f, tb[IFLA_CAN_TDC]); close_json_object();
} else {
close_json_object(); fprintf(f, "\n %s: dtseg1 %d..%d dtseg2 %d..%d "
"dsjw 1..%d dbrp %d..%d dbrp-inc %d",
dbtc->name, dbtc->tseg1_min, dbtc->tseg1_max,
dbtc->tseg2_min, dbtc->tseg2_max, dbtc->sjw_max,
dbtc->brp_min, dbtc->brp_max, dbtc->brp_inc);
}
} }
if (tb[IFLA_CAN_DATA_BITRATE_CONST]) { if (tb[IFLA_CAN_DATA_BITRATE_CONST]) {
@ -572,23 +497,30 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
dbitrate = dbt->bitrate; dbitrate = dbt->bitrate;
} }
can_print_nl_indent(); if (is_json_context()) {
print_uint(PRINT_ANY, "data_bittiming_bitrate", " dbitrate %u", print_uint(PRINT_JSON, "data_bittiming_bitrate",
dbitrate); NULL, dbitrate);
can_print_nl_indent(); open_json_array(PRINT_JSON, "data_bitrate_const");
open_json_array(PRINT_ANY, is_json_context() ? for (i = 0; i < dbitrate_cnt; ++i)
"data_bitrate_const" : " ["); print_uint(PRINT_JSON, NULL, NULL,
for (i = 0; i < dbitrate_cnt; ++i) { dbitrate_const[i]);
/* This will keep lines below 80 signs */ close_json_array(PRINT_JSON, NULL);
if (!(i % 6) && i) { } else {
can_print_nl_indent(); fprintf(f, "\n dbitrate %u", dbitrate);
print_string(PRINT_FP, NULL, "%s", " "); fprintf(f, "\n [");
for (i = 0; i < dbitrate_cnt - 1; ++i) {
/* This will keep lines below 80 signs */
if (!(i % 6) && i)
fprintf(f, "\n ");
fprintf(f, "%8u, ", dbitrate_const[i]);
} }
print_uint(PRINT_ANY, NULL,
i < dbitrate_cnt - 1 ? "%8u, " : "%8u", if (!(i % 6) && i)
dbitrate_const[i]); fprintf(f, "\n ");
fprintf(f, "%8u ]", dbitrate_const[i]);
} }
close_json_array(PRINT_JSON, " ]");
} }
if (tb[IFLA_CAN_TERMINATION_CONST] && tb[IFLA_CAN_TERMINATION]) { if (tb[IFLA_CAN_TERMINATION_CONST] && tb[IFLA_CAN_TERMINATION]) {
@ -598,21 +530,29 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
sizeof(*trm_const); sizeof(*trm_const);
int i; int i;
can_print_nl_indent(); if (is_json_context()) {
print_hu(PRINT_ANY, "termination", " termination %hu [ ", *trm); print_hu(PRINT_JSON, "termination", NULL, *trm);
open_json_array(PRINT_JSON, "termination_const"); open_json_array(PRINT_JSON, "termination_const");
for (i = 0; i < trm_cnt; ++i) for (i = 0; i < trm_cnt; ++i)
print_hu(PRINT_ANY, NULL, print_hu(PRINT_JSON, NULL, NULL, trm_const[i]);
i < trm_cnt - 1 ? "%hu, " : "%hu", close_json_array(PRINT_JSON, NULL);
trm_const[i]); } else {
close_json_array(PRINT_JSON, " ]"); fprintf(f, "\n termination %hu [ ", *trm);
for (i = 0; i < trm_cnt - 1; ++i)
fprintf(f, "%hu, ", trm_const[i]);
fprintf(f, "%hu ]", trm_const[i]);
}
} }
if (tb[IFLA_CAN_CLOCK]) { if (tb[IFLA_CAN_CLOCK]) {
struct can_clock *clock = RTA_DATA(tb[IFLA_CAN_CLOCK]); struct can_clock *clock = RTA_DATA(tb[IFLA_CAN_CLOCK]);
can_print_nl_indent(); print_int(PRINT_ANY,
print_uint(PRINT_ANY, "clock", " clock %u ", clock->freq); "clock",
"\n clock %d ",
clock->freq);
} }
} }
@ -625,23 +565,31 @@ static void can_print_xstats(struct link_util *lu,
if (xstats && RTA_PAYLOAD(xstats) == sizeof(*stats)) { if (xstats && RTA_PAYLOAD(xstats) == sizeof(*stats)) {
stats = RTA_DATA(xstats); stats = RTA_DATA(xstats);
can_print_nl_indent(); if (is_json_context()) {
print_string(PRINT_FP, NULL, "%s", print_int(PRINT_JSON, "restarts",
" re-started bus-errors arbit-lost error-warn error-pass bus-off"); NULL, stats->restarts);
can_print_nl_indent(); print_int(PRINT_JSON, "bus_error",
print_uint(PRINT_ANY, "restarts", " %-10u", stats->restarts); NULL, stats->bus_error);
print_uint(PRINT_ANY, "bus_error", " %-10u", stats->bus_error); print_int(PRINT_JSON, "arbitration_lost",
print_uint(PRINT_ANY, "arbitration_lost", " %-10u", NULL, stats->arbitration_lost);
stats->arbitration_lost); print_int(PRINT_JSON, "error_warning",
print_uint(PRINT_ANY, "error_warning", " %-10u", NULL, stats->error_warning);
stats->error_warning); print_int(PRINT_JSON, "error_passive",
print_uint(PRINT_ANY, "error_passive", " %-10u", NULL, stats->error_passive);
stats->error_passive); print_int(PRINT_JSON, "bus_off", NULL, stats->bus_off);
print_uint(PRINT_ANY, "bus_off", " %-10u", stats->bus_off); } else {
fprintf(f, "\n re-started bus-errors arbit-lost "
"error-warn error-pass bus-off");
fprintf(f, "\n %-10d %-10d %-10d %-10d %-10d %-10d",
stats->restarts, stats->bus_error,
stats->arbitration_lost, stats->error_warning,
stats->error_passive, stats->bus_off);
}
} }
} }
static void can_print_help(struct link_util *lu, int argc, char **argv, FILE *f) static void can_print_help(struct link_util *lu, int argc, char **argv,
FILE *f)
{ {
print_usage(f); print_usage(f);
} }

View File

@ -243,6 +243,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{ {
__u32 vni;
__u8 ttl = 0; __u8 ttl = 0;
__u8 tos = 0; __u8 tos = 0;
@ -251,12 +252,15 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (tb[IFLA_GENEVE_COLLECT_METADATA]) { if (tb[IFLA_GENEVE_COLLECT_METADATA]) {
print_bool(PRINT_ANY, "external", "external ", true); print_bool(PRINT_ANY, "external", "external ", true);
return;
} }
if (tb[IFLA_GENEVE_ID] && if (!tb[IFLA_GENEVE_ID] ||
RTA_PAYLOAD(tb[IFLA_GENEVE_ID]) >= sizeof(__u32)) { RTA_PAYLOAD(tb[IFLA_GENEVE_ID]) < sizeof(__u32))
print_uint(PRINT_ANY, "id", "id %u ", rta_getattr_u32(tb[IFLA_GENEVE_ID])); return;
}
vni = rta_getattr_u32(tb[IFLA_GENEVE_ID]);
print_uint(PRINT_ANY, "id", "id %u ", vni);
if (tb[IFLA_GENEVE_REMOTE]) { if (tb[IFLA_GENEVE_REMOTE]) {
__be32 addr = rta_getattr_u32(tb[IFLA_GENEVE_REMOTE]); __be32 addr = rta_getattr_u32(tb[IFLA_GENEVE_REMOTE]);

View File

@ -33,7 +33,7 @@ static void print_explain(struct link_util *lu, FILE *f)
"Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS [bcqueuelen BC_QUEUE_LEN]\n" "Usage: ... %s mode MODE [flag MODE_FLAG] MODE_OPTS [bcqueuelen BC_QUEUE_LEN]\n"
"\n" "\n"
"MODE: private | vepa | bridge | passthru | source\n" "MODE: private | vepa | bridge | passthru | source\n"
"MODE_FLAG: null | nopromisc | nodst\n" "MODE_FLAG: null | nopromisc\n"
"MODE_OPTS: for mode \"source\":\n" "MODE_OPTS: for mode \"source\":\n"
"\tmacaddr { { add | del } <macaddr> | set [ <macaddr> [ <macaddr> ... ] ] | flush }\n" "\tmacaddr { { add | del } <macaddr> | set [ <macaddr> [ <macaddr> ... ] ] | flush }\n"
"BC_QUEUE_LEN: Length of the rx queue for broadcast/multicast: [0-4294967295]\n", "BC_QUEUE_LEN: Length of the rx queue for broadcast/multicast: [0-4294967295]\n",
@ -58,7 +58,7 @@ static int mode_arg(const char *arg)
static int flag_arg(const char *arg) static int flag_arg(const char *arg)
{ {
fprintf(stderr, fprintf(stderr,
"Error: argument of \"flag\" must be \"nopromisc\", \"nodst\" or \"null\", not \"%s\"\n", "Error: argument of \"flag\" must be \"nopromisc\" or \"null\", not \"%s\"\n",
arg); arg);
return -1; return -1;
} }
@ -102,8 +102,6 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
if (strcmp(*argv, "nopromisc") == 0) if (strcmp(*argv, "nopromisc") == 0)
flags |= MACVLAN_FLAG_NOPROMISC; flags |= MACVLAN_FLAG_NOPROMISC;
else if (strcmp(*argv, "nodst") == 0)
flags |= MACVLAN_FLAG_NODST;
else if (strcmp(*argv, "null") == 0) else if (strcmp(*argv, "null") == 0)
flags |= 0; flags |= 0;
else else
@ -161,9 +159,6 @@ static int macvlan_parse_opt(struct link_util *lu, int argc, char **argv,
} else if (matches(*argv, "nopromisc") == 0) { } else if (matches(*argv, "nopromisc") == 0) {
flags |= MACVLAN_FLAG_NOPROMISC; flags |= MACVLAN_FLAG_NOPROMISC;
has_flags = 1; has_flags = 1;
} else if (matches(*argv, "nodst") == 0) {
flags |= MACVLAN_FLAG_NODST;
has_flags = 1;
} else if (matches(*argv, "bcqueuelen") == 0) { } else if (matches(*argv, "bcqueuelen") == 0) {
__u32 bc_queue_len; __u32 bc_queue_len;
NEXT_ARG(); NEXT_ARG();
@ -234,9 +229,6 @@ static void macvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]
if (flags & MACVLAN_FLAG_NOPROMISC) if (flags & MACVLAN_FLAG_NOPROMISC)
print_bool(PRINT_ANY, "nopromisc", "nopromisc ", true); print_bool(PRINT_ANY, "nopromisc", "nopromisc ", true);
if (flags & MACVLAN_FLAG_NODST)
print_bool(PRINT_ANY, "nodst", "nodst ", true);
if (tb[IFLA_MACVLAN_BC_QUEUE_LEN] && if (tb[IFLA_MACVLAN_BC_QUEUE_LEN] &&
RTA_PAYLOAD(tb[IFLA_MACVLAN_BC_QUEUE_LEN]) >= sizeof(__u32)) { RTA_PAYLOAD(tb[IFLA_MACVLAN_BC_QUEUE_LEN]) >= sizeof(__u32)) {
__u32 bc_queue_len = rta_getattr_u32(tb[IFLA_MACVLAN_BC_QUEUE_LEN]); __u32 bc_queue_len = rta_getattr_u32(tb[IFLA_MACVLAN_BC_QUEUE_LEN]);

View File

@ -408,6 +408,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{ {
__u32 vni;
__u8 ttl = 0; __u8 ttl = 0;
__u8 tos = 0; __u8 tos = 0;
__u32 maxaddr; __u32 maxaddr;
@ -418,12 +419,15 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (tb[IFLA_VXLAN_COLLECT_METADATA] && if (tb[IFLA_VXLAN_COLLECT_METADATA] &&
rta_getattr_u8(tb[IFLA_VXLAN_COLLECT_METADATA])) { rta_getattr_u8(tb[IFLA_VXLAN_COLLECT_METADATA])) {
print_bool(PRINT_ANY, "external", "external ", true); print_bool(PRINT_ANY, "external", "external ", true);
return;
} }
if (tb[IFLA_VXLAN_ID] && if (!tb[IFLA_VXLAN_ID] ||
RTA_PAYLOAD(tb[IFLA_VXLAN_ID]) >= sizeof(__u32)) { RTA_PAYLOAD(tb[IFLA_VXLAN_ID]) < sizeof(__u32))
print_uint(PRINT_ANY, "id", "id %u ", rta_getattr_u32(tb[IFLA_VXLAN_ID])); return;
}
vni = rta_getattr_u32(tb[IFLA_VXLAN_ID]);
print_uint(PRINT_ANY, "id", "id %u ", vni);
if (tb[IFLA_VXLAN_GROUP]) { if (tb[IFLA_VXLAN_GROUP]) {
__be32 addr = rta_getattr_u32(tb[IFLA_VXLAN_GROUP]); __be32 addr = rta_getattr_u32(tb[IFLA_VXLAN_GROUP]);

View File

@ -1,72 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <stdio.h>
#include <linux/netlink.h>
#include <linux/wwan.h>
#include "utils.h"
#include "ip_common.h"
static void print_explain(FILE *f)
{
fprintf(f,
"Usage: ... wwan linkid LINKID\n"
"\n"
"Where: LINKID := 0-4294967295\n"
);
}
static void explain(void)
{
print_explain(stderr);
}
static int wwan_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
while (argc > 0) {
if (matches(*argv, "linkid") == 0) {
__u32 linkid;
NEXT_ARG();
if (get_u32(&linkid, *argv, 0))
invarg("linkid", *argv);
addattr32(n, 1024, IFLA_WWAN_LINK_ID, linkid);
} else if (matches(*argv, "help") == 0) {
explain();
return -1;
} else {
fprintf(stderr, "wwan: unknown command \"%s\"?\n",
*argv);
explain();
return -1;
}
argc--, argv++;
}
return 0;
}
static void wwan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
if (!tb)
return;
if (tb[IFLA_WWAN_LINK_ID])
print_uint(PRINT_ANY, "linkid", "linkid %u ",
rta_getattr_u32(tb[IFLA_WWAN_LINK_ID]));
}
static void wwan_print_help(struct link_util *lu, int argc, char **argv,
FILE *f)
{
print_explain(f);
}
struct link_util wwan_link_util = {
.id = "wwan",
.maxattr = IFLA_WWAN_MAX,
.parse_opt = wwan_parse_opt,
.print_opt = wwan_print_opt,
.print_help = wwan_print_help,
};

View File

@ -22,7 +22,6 @@
#include "utils.h" #include "utils.h"
#include "ip_common.h" #include "ip_common.h"
#include "nh_common.h"
static void usage(void) __attribute__((noreturn)); static void usage(void) __attribute__((noreturn));
static int prefix_banner; static int prefix_banner;
@ -89,13 +88,7 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl,
case RTM_NEWNEXTHOP: case RTM_NEWNEXTHOP:
case RTM_DELNEXTHOP: case RTM_DELNEXTHOP:
print_headers(fp, "[NEXTHOP]", ctrl); print_headers(fp, "[NEXTHOP]", ctrl);
print_cache_nexthop(n, arg, true); print_nexthop(n, arg);
return 0;
case RTM_NEWNEXTHOPBUCKET:
case RTM_DELNEXTHOPBUCKET:
print_headers(fp, "[NEXTHOPBUCKET]", ctrl);
print_nexthop_bucket(n, arg);
return 0; return 0;
case RTM_NEWLINK: case RTM_NEWLINK:

View File

@ -1,35 +1,28 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <rt_names.h>
#include <errno.h>
#include <linux/genetlink.h> #include <linux/genetlink.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/mptcp.h> #include <linux/mptcp.h>
#include "utils.h" #include "utils.h"
#include "ip_common.h" #include "ip_common.h"
#include "json_print.h"
#include "libgenl.h" #include "libgenl.h"
#include "libnetlink.h" #include "json_print.h"
#include "ll_map.h"
static void usage(void) static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n" "Usage: ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n"
" [ port NR ] [ FLAG-LIST ]\n" " [ FLAG-LIST ]\n"
" ip mptcp endpoint delete id ID\n" " ip mptcp endpoint delete id ID\n"
" ip mptcp endpoint show [ id ID ]\n" " ip mptcp endpoint show [ id ID ]\n"
" ip mptcp endpoint flush\n" " ip mptcp endpoint flush\n"
" ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n" " ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
" ip mptcp limits show\n" " ip mptcp limits show\n"
" ip mptcp monitor\n"
"FLAG-LIST := [ FLAG-LIST ] FLAG\n" "FLAG-LIST := [ FLAG-LIST ] FLAG\n"
"FLAG := [ signal | subflow | backup ]\n"); "FLAG := [ signal | subflow | backup ]\n");
@ -104,7 +97,6 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
bool id_set = false; bool id_set = false;
__u32 index = 0; __u32 index = 0;
__u32 flags = 0; __u32 flags = 0;
__u16 port = 0;
__u8 id = 0; __u8 id = 0;
ll_init_map(&rth); ll_init_map(&rth);
@ -131,10 +123,6 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
if (!index) if (!index)
invarg("device does not exist\n", ifname); invarg("device does not exist\n", ifname);
} else if (matches(*argv, "port") == 0) {
NEXT_ARG();
if (get_u16(&port, *argv, 0))
invarg("expected port", *argv);
} else if (get_addr(&address, *argv, AF_UNSPEC) == 0) { } else if (get_addr(&address, *argv, AF_UNSPEC) == 0) {
addr_set = true; addr_set = true;
} else { } else {
@ -149,9 +137,6 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
if (!id_set && !adding) if (!id_set && !adding)
missarg("ID"); missarg("ID");
if (port && !(flags & MPTCP_PM_ADDR_FLAG_SIGNAL))
invarg("flags must have signal when using port", "port");
attr_addr = addattr_nest(n, MPTCP_BUFLEN, attr_addr = addattr_nest(n, MPTCP_BUFLEN,
MPTCP_PM_ATTR_ADDR | NLA_F_NESTED); MPTCP_PM_ATTR_ADDR | NLA_F_NESTED);
if (id_set) if (id_set)
@ -160,8 +145,6 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_FLAGS, flags); addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_FLAGS, flags);
if (index) if (index)
addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_IF_IDX, index); addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_IF_IDX, index);
if (port)
addattr16(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_PORT, port);
if (addr_set) { if (addr_set) {
int type; int type;
@ -198,8 +181,8 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
__u8 family = AF_UNSPEC, addr_attr_type; __u8 family = AF_UNSPEC, addr_attr_type;
const char *ifname; const char *ifname;
unsigned int flags; unsigned int flags;
__u16 id, port;
int index; int index;
__u16 id;
parse_rtattr_nested(tb, MPTCP_PM_ADDR_ATTR_MAX, addrinfo); parse_rtattr_nested(tb, MPTCP_PM_ADDR_ATTR_MAX, addrinfo);
@ -213,11 +196,6 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
print_string(PRINT_ANY, "address", "%s ", print_string(PRINT_ANY, "address", "%s ",
format_host_rta(family, tb[addr_attr_type])); format_host_rta(family, tb[addr_attr_type]));
} }
if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {
port = rta_getattr_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]);
if (port)
print_uint(PRINT_ANY, "port", "port %u ", port);
}
if (tb[MPTCP_PM_ADDR_ATTR_ID]) { if (tb[MPTCP_PM_ADDR_ATTR_ID]) {
id = rta_getattr_u8(tb[MPTCP_PM_ADDR_ATTR_ID]); id = rta_getattr_u8(tb[MPTCP_PM_ADDR_ATTR_ID]);
print_uint(PRINT_ANY, "id", "id %u ", id); print_uint(PRINT_ANY, "id", "id %u ", id);
@ -284,7 +262,7 @@ static int mptcp_addr_dump(void)
return -2; return -2;
} }
delete_json_obj(); close_json_object();
fflush(stdout); fflush(stdout);
return 0; return 0;
} }
@ -305,11 +283,7 @@ static int mptcp_addr_show(int argc, char **argv)
if (rtnl_talk(&genl_rth, &req.n, &answer) < 0) if (rtnl_talk(&genl_rth, &req.n, &answer) < 0)
return -2; return -2;
new_json_obj(json); return print_mptcp_addr(answer, stdout);
ret = print_mptcp_addr(answer, stdout);
delete_json_obj();
fflush(stdout);
return ret;
} }
static int mptcp_addr_flush(int argc, char **argv) static int mptcp_addr_flush(int argc, char **argv)
@ -411,110 +385,6 @@ static int mptcp_limit_get_set(int argc, char **argv, int cmd)
return 0; return 0;
} }
static const char * const event_to_str[] = {
[MPTCP_EVENT_CREATED] = "CREATED",
[MPTCP_EVENT_ESTABLISHED] = "ESTABLISHED",
[MPTCP_EVENT_CLOSED] = "CLOSED",
[MPTCP_EVENT_ANNOUNCED] = "ANNOUNCED",
[MPTCP_EVENT_REMOVED] = "REMOVED",
[MPTCP_EVENT_SUB_ESTABLISHED] = "SF_ESTABLISHED",
[MPTCP_EVENT_SUB_CLOSED] = "SF_CLOSED",
[MPTCP_EVENT_SUB_PRIORITY] = "SF_PRIO",
};
static void print_addr(const char *key, int af, struct rtattr *value)
{
void *data = RTA_DATA(value);
char str[INET6_ADDRSTRLEN];
if (inet_ntop(af, data, str, sizeof(str)))
printf(" %s=%s", key, str);
}
static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,
struct nlmsghdr *n, void *arg)
{
const struct genlmsghdr *ghdr = NLMSG_DATA(n);
struct rtattr *tb[MPTCP_ATTR_MAX + 1];
int len = n->nlmsg_len;
len -= NLMSG_LENGTH(GENL_HDRLEN);
if (len < 0)
return -1;
if (n->nlmsg_type != genl_family)
return 0;
if (timestamp)
print_timestamp(stdout);
if (ghdr->cmd >= ARRAY_SIZE(event_to_str)) {
printf("[UNKNOWN %u]\n", ghdr->cmd);
goto out;
}
if (event_to_str[ghdr->cmd] == NULL) {
printf("[UNKNOWN %u]\n", ghdr->cmd);
goto out;
}
printf("[%14s]", event_to_str[ghdr->cmd]);
parse_rtattr(tb, MPTCP_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, len);
printf(" token=%08x", rta_getattr_u32(tb[MPTCP_ATTR_TOKEN]));
if (tb[MPTCP_ATTR_REM_ID])
printf(" remid=%u", rta_getattr_u8(tb[MPTCP_ATTR_REM_ID]));
if (tb[MPTCP_ATTR_LOC_ID])
printf(" locid=%u", rta_getattr_u8(tb[MPTCP_ATTR_LOC_ID]));
if (tb[MPTCP_ATTR_SADDR4])
print_addr("saddr4", AF_INET, tb[MPTCP_ATTR_SADDR4]);
if (tb[MPTCP_ATTR_DADDR4])
print_addr("daddr4", AF_INET, tb[MPTCP_ATTR_DADDR4]);
if (tb[MPTCP_ATTR_SADDR6])
print_addr("saddr6", AF_INET6, tb[MPTCP_ATTR_SADDR6]);
if (tb[MPTCP_ATTR_DADDR6])
print_addr("daddr6", AF_INET6, tb[MPTCP_ATTR_DADDR6]);
if (tb[MPTCP_ATTR_SPORT])
printf(" sport=%u", rta_getattr_be16(tb[MPTCP_ATTR_SPORT]));
if (tb[MPTCP_ATTR_DPORT])
printf(" dport=%u", rta_getattr_be16(tb[MPTCP_ATTR_DPORT]));
if (tb[MPTCP_ATTR_BACKUP])
printf(" backup=%d", rta_getattr_u8(tb[MPTCP_ATTR_BACKUP]));
if (tb[MPTCP_ATTR_ERROR])
printf(" error=%d", rta_getattr_u8(tb[MPTCP_ATTR_ERROR]));
if (tb[MPTCP_ATTR_FLAGS])
printf(" flags=%x", rta_getattr_u16(tb[MPTCP_ATTR_FLAGS]));
if (tb[MPTCP_ATTR_TIMEOUT])
printf(" timeout=%u", rta_getattr_u32(tb[MPTCP_ATTR_TIMEOUT]));
if (tb[MPTCP_ATTR_IF_IDX])
printf(" ifindex=%d", rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
if (tb[MPTCP_ATTR_RESET_REASON])
printf(" reset_reason=%u", rta_getattr_u32(tb[MPTCP_ATTR_RESET_REASON]));
if (tb[MPTCP_ATTR_RESET_FLAGS])
printf(" reset_flags=0x%x", rta_getattr_u32(tb[MPTCP_ATTR_RESET_FLAGS]));
puts("");
out:
fflush(stdout);
return 0;
}
static int mptcp_monitor(void)
{
if (genl_add_mcast_grp(&genl_rth, genl_family, MPTCP_PM_EV_GRP_NAME) < 0) {
perror("can't subscribe to mptcp events");
return 1;
}
if (rtnl_listen(&genl_rth, mptcp_monitor_msg, stdout) < 0)
return 2;
return 0;
}
int do_mptcp(int argc, char **argv) int do_mptcp(int argc, char **argv)
{ {
if (argc == 0) if (argc == 0)
@ -559,14 +429,6 @@ int do_mptcp(int argc, char **argv)
MPTCP_PM_CMD_GET_LIMITS); MPTCP_PM_CMD_GET_LIMITS);
} }
if (matches(*argv, "monitor") == 0) {
NEXT_ARG_FWD();
if (argc == 0)
return mptcp_monitor();
goto unknown;
}
unknown: unknown:
fprintf(stderr, "Command \"%s\" is unknown, try \"ip mptcp help\".\n", fprintf(stderr, "Command \"%s\" is unknown, try \"ip mptcp help\".\n",
*argv); *argv);

View File

@ -37,8 +37,8 @@ static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: ip mroute show [ [ to ] PREFIX ] [ from PREFIX ] [ iif DEVICE ]\n" "Usage: ip mroute show [ [ to ] PREFIX ] [ from PREFIX ] [ iif DEVICE ]\n"
" [ table TABLE_ID ]\n" " [ table TABLE_ID ]\n"
"TABLE_ID := [ local | main | default | all | NUMBER ]\n" "TABLE_ID := [ local | main | default | all | NUMBER ]\n"
#if 0 #if 0
"Usage: ip mroute [ add | del ] DESTINATION from SOURCE [ iif DEVICE ] [ oif DEVICE ]\n" "Usage: ip mroute [ add | del ] DESTINATION from SOURCE [ iif DEVICE ] [ oif DEVICE ]\n"
#endif #endif

View File

@ -50,12 +50,11 @@ static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: ip neigh { add | del | change | replace }\n" "Usage: ip neigh { add | del | change | replace }\n"
" { ADDR [ lladdr LLADDR ] [ nud STATE ] proxy ADDR }\n" " { ADDR [ lladdr LLADDR ] [ nud STATE ] proxy ADDR }\n"
" [ dev DEV ] [ router ] [ use ] [ managed ] [ extern_learn ]\n" " [ dev DEV ] [ router ] [ extern_learn ] [ protocol PROTO ]\n"
" [ protocol PROTO ]\n"
"\n" "\n"
" ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n" " ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n"
" [ vrf NAME ] [ nomaster ]\n" " [ vrf NAME ]\n"
" ip neigh get { ADDR | proxy ADDR } dev DEV\n" " ip neigh get { ADDR | proxy ADDR } dev DEV\n"
"\n" "\n"
"STATE := { delay | failed | incomplete | noarp | none |\n" "STATE := { delay | failed | incomplete | noarp | none |\n"
@ -116,7 +115,6 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv)
.ndm.ndm_family = preferred_family, .ndm.ndm_family = preferred_family,
.ndm.ndm_state = NUD_PERMANENT, .ndm.ndm_state = NUD_PERMANENT,
}; };
__u32 ext_flags = 0;
char *dev = NULL; char *dev = NULL;
int dst_ok = 0; int dst_ok = 0;
int dev_ok = 0; int dev_ok = 0;
@ -150,11 +148,6 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv)
req.ndm.ndm_flags |= NTF_PROXY; req.ndm.ndm_flags |= NTF_PROXY;
} else if (strcmp(*argv, "router") == 0) { } else if (strcmp(*argv, "router") == 0) {
req.ndm.ndm_flags |= NTF_ROUTER; req.ndm.ndm_flags |= NTF_ROUTER;
} else if (strcmp(*argv, "use") == 0) {
req.ndm.ndm_flags |= NTF_USE;
} else if (strcmp(*argv, "managed") == 0) {
ext_flags |= NTF_EXT_MANAGED;
req.ndm.ndm_state = NUD_NONE;
} else if (matches(*argv, "extern_learn") == 0) { } else if (matches(*argv, "extern_learn") == 0) {
req.ndm.ndm_flags |= NTF_EXT_LEARNED; req.ndm.ndm_flags |= NTF_EXT_LEARNED;
} else if (strcmp(*argv, "dev") == 0) { } else if (strcmp(*argv, "dev") == 0) {
@ -190,10 +183,7 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv)
req.ndm.ndm_family = dst.family; req.ndm.ndm_family = dst.family;
if (addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen) < 0) if (addattr_l(&req.n, sizeof(req), NDA_DST, &dst.data, dst.bytelen) < 0)
return -1; return -1;
if (ext_flags &&
addattr_l(&req.n, sizeof(req), NDA_FLAGS_EXT, &ext_flags,
sizeof(ext_flags)) < 0)
return -1;
if (lla && strcmp(lla, "null")) { if (lla && strcmp(lla, "null")) {
char llabuf[20]; char llabuf[20];
int l; int l;
@ -245,7 +235,7 @@ static void print_neigh_state(unsigned int nud)
#define PRINT_FLAG(f) \ #define PRINT_FLAG(f) \
if (nud & NUD_##f) { \ if (nud & NUD_##f) { \
nud &= ~NUD_##f; \ nud &= ~NUD_##f; \
print_string(PRINT_ANY, NULL, "%s ", #f); \ print_string(PRINT_ANY, NULL, " %s", #f); \
} }
PRINT_FLAG(INCOMPLETE); PRINT_FLAG(INCOMPLETE);
@ -261,51 +251,6 @@ static void print_neigh_state(unsigned int nud)
close_json_array(PRINT_JSON, NULL); close_json_array(PRINT_JSON, NULL);
} }
static int print_neigh_brief(FILE *fp, struct ndmsg *r, struct rtattr *tb[])
{
if (tb[NDA_DST]) {
const char *dst;
int family = r->ndm_family;
if (family == AF_BRIDGE) {
if (RTA_PAYLOAD(tb[NDA_DST]) == sizeof(struct in6_addr))
family = AF_INET6;
else
family = AF_INET;
}
dst = format_host_rta(family, tb[NDA_DST]);
print_color_string(PRINT_ANY, ifa_family_color(family),
"dst", "%-39s ", dst);
}
if (!filter.index && r->ndm_ifindex) {
print_color_string(PRINT_ANY, COLOR_IFNAME,
"dev", "%-16s ",
ll_index_to_name(r->ndm_ifindex));
}
if (tb[NDA_LLADDR]) {
const char *lladdr;
SPRINT_BUF(b1);
lladdr = ll_addr_n2a(RTA_DATA(tb[NDA_LLADDR]),
RTA_PAYLOAD(tb[NDA_LLADDR]),
ll_index_to_type(r->ndm_ifindex),
b1, sizeof(b1));
print_color_string(PRINT_ANY, COLOR_MAC,
"lladdr", "%s", lladdr);
}
print_string(PRINT_FP, NULL, "%s", "\n");
close_json_object();
fflush(fp);
return 0;
}
int print_neigh(struct nlmsghdr *n, void *arg) int print_neigh(struct nlmsghdr *n, void *arg)
{ {
FILE *fp = (FILE *)arg; FILE *fp = (FILE *)arg;
@ -313,7 +258,6 @@ int print_neigh(struct nlmsghdr *n, void *arg)
int len = n->nlmsg_len; int len = n->nlmsg_len;
struct rtattr *tb[NDA_MAX+1]; struct rtattr *tb[NDA_MAX+1];
static int logit = 1; static int logit = 1;
__u32 ext_flags = 0;
__u8 protocol = 0; __u8 protocol = 0;
if (n->nlmsg_type != RTM_NEWNEIGH && n->nlmsg_type != RTM_DELNEIGH && if (n->nlmsg_type != RTM_NEWNEIGH && n->nlmsg_type != RTM_DELNEIGH &&
@ -339,7 +283,8 @@ int print_neigh(struct nlmsghdr *n, void *arg)
if (!(filter.state&r->ndm_state) && if (!(filter.state&r->ndm_state) &&
!(r->ndm_flags & NTF_PROXY) && !(r->ndm_flags & NTF_PROXY) &&
!(r->ndm_flags & NTF_EXT_LEARNED) && !(r->ndm_flags & NTF_EXT_LEARNED) &&
(r->ndm_state || !(filter.state&0x100))) (r->ndm_state || !(filter.state&0x100)) &&
(r->ndm_family != AF_DECnet))
return 0; return 0;
if (filter.master && !(n->nlmsg_flags & NLM_F_DUMP_FILTERED)) { if (filter.master && !(n->nlmsg_flags & NLM_F_DUMP_FILTERED)) {
@ -357,8 +302,6 @@ int print_neigh(struct nlmsghdr *n, void *arg)
if (tb[NDA_PROTOCOL]) if (tb[NDA_PROTOCOL])
protocol = rta_getattr_u8(tb[NDA_PROTOCOL]); protocol = rta_getattr_u8(tb[NDA_PROTOCOL]);
if (tb[NDA_FLAGS_EXT])
ext_flags = rta_getattr_u32(tb[NDA_FLAGS_EXT]);
if (filter.protocol && filter.protocol != protocol) if (filter.protocol && filter.protocol != protocol)
return 0; return 0;
@ -394,9 +337,6 @@ int print_neigh(struct nlmsghdr *n, void *arg)
else if (n->nlmsg_type == RTM_GETNEIGH) else if (n->nlmsg_type == RTM_GETNEIGH)
print_null(PRINT_ANY, "miss", "%s ", "miss"); print_null(PRINT_ANY, "miss", "%s ", "miss");
if (brief)
return print_neigh_brief(fp, r, tb);
if (tb[NDA_DST]) { if (tb[NDA_DST]) {
const char *dst; const char *dst;
int family = r->ndm_family; int family = r->ndm_family;
@ -436,26 +376,27 @@ int print_neigh(struct nlmsghdr *n, void *arg)
fprintf(fp, "lladdr "); fprintf(fp, "lladdr ");
print_color_string(PRINT_ANY, COLOR_MAC, print_color_string(PRINT_ANY, COLOR_MAC,
"lladdr", "%s ", lladdr); "lladdr", "%s", lladdr);
} }
if (r->ndm_flags & NTF_ROUTER) if (r->ndm_flags & NTF_ROUTER)
print_null(PRINT_ANY, "router", "%s ", "router"); print_null(PRINT_ANY, "router", " %s", "router");
if (r->ndm_flags & NTF_PROXY) if (r->ndm_flags & NTF_PROXY)
print_null(PRINT_ANY, "proxy", "%s ", "proxy"); print_null(PRINT_ANY, "proxy", " %s", "proxy");
if (ext_flags & NTF_EXT_MANAGED)
print_null(PRINT_ANY, "managed", "%s ", "managed");
if (r->ndm_flags & NTF_EXT_LEARNED) if (r->ndm_flags & NTF_EXT_LEARNED)
print_null(PRINT_ANY, "extern_learn", "%s ", "extern_learn"); print_null(PRINT_ANY, "extern_learn", " %s ", "extern_learn");
if (r->ndm_flags & NTF_OFFLOADED) if (r->ndm_flags & NTF_OFFLOADED)
print_null(PRINT_ANY, "offload", "%s ", "offload"); print_null(PRINT_ANY, "offload", " %s", "offload");
if (show_stats) { if (show_stats) {
if (tb[NDA_CACHEINFO]) if (tb[NDA_CACHEINFO])
print_cacheinfo(RTA_DATA(tb[NDA_CACHEINFO])); print_cacheinfo(RTA_DATA(tb[NDA_CACHEINFO]));
if (tb[NDA_PROBES]) if (tb[NDA_PROBES])
print_uint(PRINT_ANY, "probes", "probes %u ", print_uint(PRINT_ANY, "probes", " probes %u",
rta_getattr_u32(tb[NDA_PROBES])); rta_getattr_u32(tb[NDA_PROBES]));
} }
@ -465,13 +406,13 @@ int print_neigh(struct nlmsghdr *n, void *arg)
if (protocol) { if (protocol) {
SPRINT_BUF(b1); SPRINT_BUF(b1);
print_string(PRINT_ANY, "protocol", "proto %s ", print_string(PRINT_ANY, "protocol", " proto %s ",
rtnl_rtprot_n2a(protocol, b1, sizeof(b1))); rtnl_rtprot_n2a(protocol, b1, sizeof(b1)));
} }
print_string(PRINT_FP, NULL, "\n", ""); print_string(PRINT_FP, NULL, "\n", "");
close_json_object(); close_json_object();
fflush(fp); fflush(stdout);
return 0; return 0;
} }
@ -547,8 +488,6 @@ static int do_show_or_flush(int argc, char **argv, int flush)
if (!name_is_vrf(*argv)) if (!name_is_vrf(*argv))
invarg("Not a valid VRF name\n", *argv); invarg("Not a valid VRF name\n", *argv);
filter.master = ifindex; filter.master = ifindex;
} else if (strcmp(*argv, "nomaster") == 0) {
filter.master = -1;
} else if (strcmp(*argv, "unused") == 0) { } else if (strcmp(*argv, "unused") == 0) {
filter.unused_only = 1; filter.unused_only = 1;
} else if (strcmp(*argv, "nud") == 0) { } else if (strcmp(*argv, "nud") == 0) {

File diff suppressed because it is too large Load Diff

View File

@ -47,15 +47,15 @@ static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: ip ntable change name NAME [ dev DEV ]\n" "Usage: ip ntable change name NAME [ dev DEV ]\n"
" [ thresh1 VAL ] [ thresh2 VAL ] [ thresh3 VAL ] [ gc_int MSEC ]\n" " [ thresh1 VAL ] [ thresh2 VAL ] [ thresh3 VAL ] [ gc_int MSEC ]\n"
" [ PARMS ]\n" " [ PARMS ]\n"
"Usage: ip ntable show [ dev DEV ] [ name NAME ]\n" "Usage: ip ntable show [ dev DEV ] [ name NAME ]\n"
"PARMS := [ base_reachable MSEC ] [ retrans MSEC ] [ gc_stale MSEC ]\n" "PARMS := [ base_reachable MSEC ] [ retrans MSEC ] [ gc_stale MSEC ]\n"
" [ delay_probe MSEC ] [ queue LEN ]\n" " [ delay_probe MSEC ] [ queue LEN ]\n"
" [ app_probes VAL ] [ ucast_probes VAL ] [ mcast_probes VAL ]\n" " [ app_probes VAL ] [ ucast_probes VAL ] [ mcast_probes VAL ]\n"
" [ anycast_delay MSEC ] [ proxy_delay MSEC ] [ proxy_queue LEN ]\n" " [ anycast_delay MSEC ] [ proxy_delay MSEC ] [ proxy_queue LEN ]\n"
" [ locktime MSEC ]\n" " [ locktime MSEC ]\n"
); );
exit(-1); exit(-1);

View File

@ -28,7 +28,6 @@
#include "rt_names.h" #include "rt_names.h"
#include "utils.h" #include "utils.h"
#include "ip_common.h" #include "ip_common.h"
#include "nh_common.h"
#ifndef RTAX_RTTVAR #ifndef RTAX_RTTVAR
#define RTAX_RTTVAR RTAX_HOPS #define RTAX_RTTVAR RTAX_HOPS
@ -83,7 +82,7 @@ static void usage(void)
" [ ttl-propagate { enabled | disabled } ]\n" " [ ttl-propagate { enabled | disabled } ]\n"
"INFO_SPEC := { NH | nhid ID } OPTIONS FLAGS [ nexthop NH ]...\n" "INFO_SPEC := { NH | nhid ID } OPTIONS FLAGS [ nexthop NH ]...\n"
"NH := [ encap ENCAPTYPE ENCAPHDR ] [ via [ FAMILY ] ADDRESS ]\n" "NH := [ encap ENCAPTYPE ENCAPHDR ] [ via [ FAMILY ] ADDRESS ]\n"
" [ dev STRING ] [ weight NUMBER ] NHFLAGS\n" " [ dev STRING ] [ weight NUMBER ] NHFLAGS\n"
"FAMILY := [ inet | inet6 | mpls | bridge | link ]\n" "FAMILY := [ inet | inet6 | mpls | bridge | link ]\n"
"OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ] [ as [ to ] ADDRESS ]\n" "OPTIONS := FLAGS [ mtu NUMBER ] [ advmss NUMBER ] [ as [ to ] ADDRESS ]\n"
" [ rtt TIME ] [ rttvar TIME ] [ reordering NUMBER ]\n" " [ rtt TIME ] [ rttvar TIME ] [ reordering NUMBER ]\n"
@ -102,18 +101,10 @@ static void usage(void)
"TIME := NUMBER[s|ms]\n" "TIME := NUMBER[s|ms]\n"
"BOOL := [1|0]\n" "BOOL := [1|0]\n"
"FEATURES := ecn\n" "FEATURES := ecn\n"
"ENCAPTYPE := [ mpls | ip | ip6 | seg6 | seg6local | rpl | ioam6 ]\n" "ENCAPTYPE := [ mpls | ip | ip6 | seg6 | seg6local | rpl ]\n"
"ENCAPHDR := [ MPLSLABEL | SEG6HDR | SEG6LOCAL | IOAM6HDR ]\n" "ENCAPHDR := [ MPLSLABEL | SEG6HDR ]\n"
"SEG6HDR := [ mode SEGMODE ] segs ADDR1,ADDRi,ADDRn [hmac HMACKEYID] [cleanup]\n" "SEG6HDR := [ mode SEGMODE ] segs ADDR1,ADDRi,ADDRn [hmac HMACKEYID] [cleanup]\n"
"SEGMODE := [ encap | inline ]\n" "SEGMODE := [ encap | inline ]\n"
"SEG6LOCAL := action ACTION [ OPTIONS ] [ count ]\n"
"ACTION := { End | End.X | End.T | End.DX2 | End.DX6 | End.DX4 |\n"
" End.DT6 | End.DT4 | End.DT46 | End.B6 | End.B6.Encaps |\n"
" End.BM | End.S | End.AS | End.AM | End.BPF }\n"
"OPTIONS := OPTION [ OPTIONS ]\n"
"OPTION := { srh SEG6HDR | nh4 ADDR | nh6 ADDR | iif DEV | oif DEV |\n"
" table TABLEID | vrftable TABLEID | endpoint PROGNAME }\n"
"IOAM6HDR := trace prealloc type IOAM6_TRACE_TYPE ns IOAM6_NAMESPACE size IOAM6_TRACE_SIZE\n"
"ROUTE_GET_FLAGS := [ fibmatch ]\n"); "ROUTE_GET_FLAGS := [ fibmatch ]\n");
exit(-1); exit(-1);
} }
@ -411,13 +402,13 @@ static void print_rt_pref(FILE *fp, unsigned int pref)
} }
} }
void print_rta_ifidx(FILE *fp, __u32 ifidx, const char *prefix) void print_rta_if(FILE *fp, const struct rtattr *rta, const char *prefix)
{ {
const char *ifname = ll_index_to_name(ifidx); const char *ifname = ll_index_to_name(rta_getattr_u32(rta));
if (is_json_context()) { if (is_json_context())
print_string(PRINT_JSON, prefix, NULL, ifname); print_string(PRINT_JSON, prefix, NULL, ifname);
} else { else {
fprintf(fp, "%s ", prefix); fprintf(fp, "%s ", prefix);
color_fprintf(fp, COLOR_IFNAME, "%s ", ifname); color_fprintf(fp, COLOR_IFNAME, "%s ", ifname);
} }
@ -548,11 +539,13 @@ static void print_rta_newdst(FILE *fp, const struct rtmsg *r,
} }
} }
void __print_rta_gateway(FILE *fp, unsigned char family, const char *gateway) void print_rta_gateway(FILE *fp, unsigned char family, const struct rtattr *rta)
{ {
if (is_json_context()) { const char *gateway = format_host_rta(family, rta);
if (is_json_context())
print_string(PRINT_JSON, "gateway", NULL, gateway); print_string(PRINT_JSON, "gateway", NULL, gateway);
} else { else {
fprintf(fp, "via "); fprintf(fp, "via ");
print_color_string(PRINT_FP, print_color_string(PRINT_FP,
ifa_family_color(family), ifa_family_color(family),
@ -560,13 +553,6 @@ void __print_rta_gateway(FILE *fp, unsigned char family, const char *gateway)
} }
} }
void print_rta_gateway(FILE *fp, unsigned char family, const struct rtattr *rta)
{
const char *gateway = format_host_rta(family, rta);
__print_rta_gateway(fp, family, gateway);
}
static void print_rta_via(FILE *fp, const struct rtattr *rta) static void print_rta_via(FILE *fp, const struct rtattr *rta)
{ {
size_t len = RTA_PAYLOAD(rta) - 2; size_t len = RTA_PAYLOAD(rta) - 2;
@ -868,7 +854,7 @@ int print_route(struct nlmsghdr *n, void *arg)
print_rta_via(fp, tb[RTA_VIA]); print_rta_via(fp, tb[RTA_VIA]);
if (tb[RTA_OIF] && filter.oifmask != -1) if (tb[RTA_OIF] && filter.oifmask != -1)
print_rta_ifidx(fp, rta_getattr_u32(tb[RTA_OIF]), "dev"); print_rta_if(fp, tb[RTA_OIF], "dev");
if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb) if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb)
print_string(PRINT_ANY, print_string(PRINT_ANY,
@ -952,7 +938,7 @@ int print_route(struct nlmsghdr *n, void *arg)
print_rta_metrics(fp, tb[RTA_METRICS]); print_rta_metrics(fp, tb[RTA_METRICS]);
if (tb[RTA_IIF] && filter.iifmask != -1) if (tb[RTA_IIF] && filter.iifmask != -1)
print_rta_ifidx(fp, rta_getattr_u32(tb[RTA_IIF]), "iif"); print_rta_if(fp, tb[RTA_IIF], "iif");
if (tb[RTA_PREF]) if (tb[RTA_PREF])
print_rt_pref(fp, rta_getattr_u8(tb[RTA_PREF])); print_rt_pref(fp, rta_getattr_u8(tb[RTA_PREF]));
@ -969,10 +955,6 @@ int print_route(struct nlmsghdr *n, void *arg)
propagate ? "enabled" : "disabled"); propagate ? "enabled" : "disabled");
} }
if (tb[RTA_NH_ID] && show_details)
print_cache_nexthop_id(fp, "\n\tnh_info ", "nh_info",
rta_getattr_u32(tb[RTA_NH_ID]));
if (tb[RTA_MULTIPATH]) if (tb[RTA_MULTIPATH])
print_rta_multipath(fp, r, tb[RTA_MULTIPATH]); print_rta_multipath(fp, r, tb[RTA_MULTIPATH]);
@ -1745,18 +1727,6 @@ static int iproute_flush(int family, rtnl_filter_t filter_fn)
} }
} }
static int save_route_errhndlr(struct nlmsghdr *n, void *arg)
{
int err = -*(int *)NLMSG_DATA(n);
if (n->nlmsg_type == NLMSG_DONE &&
filter.tb == RT_TABLE_MAIN &&
err == ENOENT)
return RTNL_SUPPRESS_NLMSG_DONE_NLERR;
return RTNL_LET_NLERR;
}
static int iproute_list_flush_or_save(int argc, char **argv, int action) static int iproute_list_flush_or_save(int argc, char **argv, int action)
{ {
int dump_family = preferred_family; int dump_family = preferred_family;
@ -1969,8 +1939,7 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
new_json_obj(json); new_json_obj(json);
if (rtnl_dump_filter_errhndlr(&rth, filter_fn, stdout, if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
save_route_errhndlr, NULL) < 0) {
fprintf(stderr, "Dump terminated\n"); fprintf(stderr, "Dump terminated\n");
return -2; return -2;
} }

View File

@ -34,8 +34,6 @@
#include <linux/seg6_hmac.h> #include <linux/seg6_hmac.h>
#include <linux/seg6_local.h> #include <linux/seg6_local.h>
#include <linux/if_tunnel.h> #include <linux/if_tunnel.h>
#include <linux/ioam6.h>
#include <linux/ioam6_iptunnel.h>
static const char *format_encap_type(int type) static const char *format_encap_type(int type)
{ {
@ -56,8 +54,6 @@ static const char *format_encap_type(int type)
return "seg6local"; return "seg6local";
case LWTUNNEL_ENCAP_RPL: case LWTUNNEL_ENCAP_RPL:
return "rpl"; return "rpl";
case LWTUNNEL_ENCAP_IOAM6:
return "ioam6";
default: default:
return "unknown"; return "unknown";
} }
@ -94,8 +90,6 @@ static int read_encap_type(const char *name)
return LWTUNNEL_ENCAP_SEG6_LOCAL; return LWTUNNEL_ENCAP_SEG6_LOCAL;
else if (strcmp(name, "rpl") == 0) else if (strcmp(name, "rpl") == 0)
return LWTUNNEL_ENCAP_RPL; return LWTUNNEL_ENCAP_RPL;
else if (strcmp(name, "ioam6") == 0)
return LWTUNNEL_ENCAP_IOAM6;
else if (strcmp(name, "help") == 0) else if (strcmp(name, "help") == 0)
encap_type_usage(); encap_type_usage();
@ -210,63 +204,6 @@ static void print_encap_rpl(FILE *fp, struct rtattr *encap)
print_rpl_srh(fp, srh); print_rpl_srh(fp, srh);
} }
static const char *ioam6_mode_types[IOAM6_IPTUNNEL_MODE_MAX + 1] = {
[IOAM6_IPTUNNEL_MODE_INLINE] = "inline",
[IOAM6_IPTUNNEL_MODE_ENCAP] = "encap",
[IOAM6_IPTUNNEL_MODE_AUTO] = "auto",
};
static const char *format_ioam6mode_type(int mode)
{
if (mode < IOAM6_IPTUNNEL_MODE_MIN ||
mode > IOAM6_IPTUNNEL_MODE_MAX ||
!ioam6_mode_types[mode])
return "<unknown>";
return ioam6_mode_types[mode];
}
static __u8 read_ioam6mode_type(const char *mode)
{
__u8 i;
for (i = IOAM6_IPTUNNEL_MODE_MIN; i <= IOAM6_IPTUNNEL_MODE_MAX; i++) {
if (ioam6_mode_types[i] && !strcmp(mode, ioam6_mode_types[i]))
return i;
}
return 0;
}
static void print_encap_ioam6(FILE *fp, struct rtattr *encap)
{
struct rtattr *tb[IOAM6_IPTUNNEL_MAX + 1];
struct ioam6_trace_hdr *trace;
__u8 mode;
parse_rtattr_nested(tb, IOAM6_IPTUNNEL_MAX, encap);
if (!tb[IOAM6_IPTUNNEL_MODE] || !tb[IOAM6_IPTUNNEL_TRACE])
return;
mode = rta_getattr_u8(tb[IOAM6_IPTUNNEL_MODE]);
if (!tb[IOAM6_IPTUNNEL_DST] && mode != IOAM6_IPTUNNEL_MODE_INLINE)
return;
print_string(PRINT_ANY, "mode", "mode %s ", format_ioam6mode_type(mode));
if (mode != IOAM6_IPTUNNEL_MODE_INLINE)
print_string(PRINT_ANY, "tundst", "tundst %s ",
rt_addr_n2a_rta(AF_INET6, tb[IOAM6_IPTUNNEL_DST]));
trace = RTA_DATA(tb[IOAM6_IPTUNNEL_TRACE]);
print_null(PRINT_ANY, "trace", "trace ", NULL);
print_null(PRINT_ANY, "prealloc", "prealloc ", NULL);
print_hex(PRINT_ANY, "type", "type %#08x ", ntohl(trace->type_be32) >> 8);
print_uint(PRINT_ANY, "ns", "ns %u ", ntohs(trace->namespace_id));
print_uint(PRINT_ANY, "size", "size %u ", trace->remlen * 4);
}
static const char *seg6_action_names[SEG6_LOCAL_ACTION_MAX + 1] = { static const char *seg6_action_names[SEG6_LOCAL_ACTION_MAX + 1] = {
[SEG6_LOCAL_ACTION_END] = "End", [SEG6_LOCAL_ACTION_END] = "End",
[SEG6_LOCAL_ACTION_END_X] = "End.X", [SEG6_LOCAL_ACTION_END_X] = "End.X",
@ -283,7 +220,6 @@ static const char *seg6_action_names[SEG6_LOCAL_ACTION_MAX + 1] = {
[SEG6_LOCAL_ACTION_END_AS] = "End.AS", [SEG6_LOCAL_ACTION_END_AS] = "End.AS",
[SEG6_LOCAL_ACTION_END_AM] = "End.AM", [SEG6_LOCAL_ACTION_END_AM] = "End.AM",
[SEG6_LOCAL_ACTION_END_BPF] = "End.BPF", [SEG6_LOCAL_ACTION_END_BPF] = "End.BPF",
[SEG6_LOCAL_ACTION_END_DT46] = "End.DT46",
}; };
static const char *format_action_type(int action) static const char *format_action_type(int action)
@ -330,42 +266,6 @@ static void print_encap_bpf_prog(FILE *fp, struct rtattr *encap,
} }
} }
static void print_seg6_local_counters(FILE *fp, struct rtattr *encap)
{
struct rtattr *tb[SEG6_LOCAL_CNT_MAX + 1];
__u64 packets = 0, bytes = 0, errors = 0;
parse_rtattr_nested(tb, SEG6_LOCAL_CNT_MAX, encap);
if (tb[SEG6_LOCAL_CNT_PACKETS])
packets = rta_getattr_u64(tb[SEG6_LOCAL_CNT_PACKETS]);
if (tb[SEG6_LOCAL_CNT_BYTES])
bytes = rta_getattr_u64(tb[SEG6_LOCAL_CNT_BYTES]);
if (tb[SEG6_LOCAL_CNT_ERRORS])
errors = rta_getattr_u64(tb[SEG6_LOCAL_CNT_ERRORS]);
if (is_json_context()) {
open_json_object("stats64");
print_u64(PRINT_JSON, "packets", NULL, packets);
print_u64(PRINT_JSON, "bytes", NULL, bytes);
print_u64(PRINT_JSON, "errors", NULL, errors);
close_json_object();
} else {
print_string(PRINT_FP, NULL, "%s ", "packets");
print_num(fp, 1, packets);
print_string(PRINT_FP, NULL, "%s ", "bytes");
print_num(fp, 1, bytes);
print_string(PRINT_FP, NULL, "%s ", "errors");
print_num(fp, 1, errors);
}
}
static void print_encap_seg6local(FILE *fp, struct rtattr *encap) static void print_encap_seg6local(FILE *fp, struct rtattr *encap)
{ {
struct rtattr *tb[SEG6_LOCAL_MAX + 1]; struct rtattr *tb[SEG6_LOCAL_MAX + 1];
@ -425,9 +325,6 @@ static void print_encap_seg6local(FILE *fp, struct rtattr *encap)
if (tb[SEG6_LOCAL_BPF]) if (tb[SEG6_LOCAL_BPF])
print_encap_bpf_prog(fp, tb[SEG6_LOCAL_BPF], "endpoint"); print_encap_bpf_prog(fp, tb[SEG6_LOCAL_BPF], "endpoint");
if (tb[SEG6_LOCAL_COUNTERS] && show_stats)
print_seg6_local_counters(fp, tb[SEG6_LOCAL_COUNTERS]);
} }
static void print_encap_mpls(FILE *fp, struct rtattr *encap) static void print_encap_mpls(FILE *fp, struct rtattr *encap)
@ -720,9 +617,6 @@ void lwt_print_encap(FILE *fp, struct rtattr *encap_type,
case LWTUNNEL_ENCAP_RPL: case LWTUNNEL_ENCAP_RPL:
print_encap_rpl(fp, encap); print_encap_rpl(fp, encap);
break; break;
case LWTUNNEL_ENCAP_IOAM6:
print_encap_ioam6(fp, encap);
break;
} }
} }
@ -919,122 +813,6 @@ out:
return ret; return ret;
} }
static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp,
char ***argvp)
{
int ns_found = 0, argc = *argcp;
__u16 trace_ns, trace_size = 0;
struct ioam6_trace_hdr *trace;
char **argv = *argvp;
__u32 trace_type = 0;
inet_prefix addr;
__u8 mode;
if (strcmp(*argv, "mode") != 0) {
mode = IOAM6_IPTUNNEL_MODE_INLINE;
} else {
NEXT_ARG();
mode = read_ioam6mode_type(*argv);
if (!mode)
invarg("Invalid mode", *argv);
NEXT_ARG();
}
if (strcmp(*argv, "tundst") != 0) {
if (mode != IOAM6_IPTUNNEL_MODE_INLINE)
missarg("tundst");
} else {
if (mode == IOAM6_IPTUNNEL_MODE_INLINE)
invarg("Inline mode does not need tundst", *argv);
NEXT_ARG();
get_addr(&addr, *argv, AF_INET6);
if (addr.family != AF_INET6 || addr.bytelen != 16)
invarg("Invalid IPv6 address for tundst", *argv);
NEXT_ARG();
}
if (strcmp(*argv, "trace") != 0)
missarg("trace");
NEXT_ARG();
if (strcmp(*argv, "prealloc") != 0)
missarg("prealloc");
while (NEXT_ARG_OK()) {
NEXT_ARG_FWD();
if (strcmp(*argv, "type") == 0) {
NEXT_ARG();
if (trace_type)
duparg2("type", *argv);
if (get_u32(&trace_type, *argv, 0) || !trace_type)
invarg("Invalid trace type", *argv);
} else if (strcmp(*argv, "ns") == 0) {
NEXT_ARG();
if (ns_found++)
duparg2("ns", *argv);
if (get_u16(&trace_ns, *argv, 0))
invarg("Invalid namespace ID", *argv);
} else if (strcmp(*argv, "size") == 0) {
NEXT_ARG();
if (trace_size)
duparg2("size", *argv);
if (get_u16(&trace_size, *argv, 0) || !trace_size)
invarg("Invalid trace size", *argv);
if (trace_size % 4)
invarg("Trace size must be a 4-octet multiple",
*argv);
if (trace_size > IOAM6_TRACE_DATA_SIZE_MAX)
invarg("Trace size is too big", *argv);
} else {
break;
}
}
if (!trace_type)
missarg("type");
if (!ns_found)
missarg("ns");
if (!trace_size)
missarg("size");
trace = calloc(1, sizeof(*trace));
if (!trace)
return -1;
trace->type_be32 = htonl(trace_type << 8);
trace->namespace_id = htons(trace_ns);
trace->remlen = (__u8)(trace_size / 4);
if (rta_addattr8(rta, len, IOAM6_IPTUNNEL_MODE, mode) ||
(mode != IOAM6_IPTUNNEL_MODE_INLINE &&
rta_addattr_l(rta, len, IOAM6_IPTUNNEL_DST, &addr.data, addr.bytelen)) ||
rta_addattr_l(rta, len, IOAM6_IPTUNNEL_TRACE, trace, sizeof(*trace))) {
free(trace);
return -1;
}
*argcp = argc + 1;
*argvp = argv - 1;
free(trace);
return 0;
}
struct lwt_x { struct lwt_x {
struct rtattr *rta; struct rtattr *rta;
size_t len; size_t len;
@ -1084,39 +862,13 @@ static int lwt_parse_bpf(struct rtattr *rta, size_t len,
return 0; return 0;
} }
/* for the moment, counters are always initialized to zero by the kernel; so we
* do not expect to parse any argument here.
*/
static int seg6local_fill_counters(struct rtattr *rta, size_t len, int attr)
{
struct rtattr *nest;
int ret;
nest = rta_nest(rta, len, attr);
ret = rta_addattr64(rta, len, SEG6_LOCAL_CNT_PACKETS, 0);
if (ret < 0)
return ret;
ret = rta_addattr64(rta, len, SEG6_LOCAL_CNT_BYTES, 0);
if (ret < 0)
return ret;
ret = rta_addattr64(rta, len, SEG6_LOCAL_CNT_ERRORS, 0);
if (ret < 0)
return ret;
rta_nest_end(rta, nest);
return 0;
}
static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp, static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp,
char ***argvp) char ***argvp)
{ {
int segs_ok = 0, hmac_ok = 0, table_ok = 0, vrftable_ok = 0; int segs_ok = 0, hmac_ok = 0, table_ok = 0, vrftable_ok = 0;
int action_ok = 0, srh_ok = 0, bpf_ok = 0, counters_ok = 0;
int nh4_ok = 0, nh6_ok = 0, iif_ok = 0, oif_ok = 0; int nh4_ok = 0, nh6_ok = 0, iif_ok = 0, oif_ok = 0;
__u32 action = 0, table, vrftable, iif, oif; __u32 action = 0, table, vrftable, iif, oif;
int action_ok = 0, srh_ok = 0, bpf_ok = 0;
struct ipv6_sr_hdr *srh; struct ipv6_sr_hdr *srh;
char **argv = *argvp; char **argv = *argvp;
int argc = *argcp; int argc = *argcp;
@ -1180,11 +932,6 @@ static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp,
if (!oif) if (!oif)
exit(nodev(*argv)); exit(nodev(*argv));
ret = rta_addattr32(rta, len, SEG6_LOCAL_OIF, oif); ret = rta_addattr32(rta, len, SEG6_LOCAL_OIF, oif);
} else if (strcmp(*argv, "count") == 0) {
if (counters_ok++)
duparg2("count", *argv);
ret = seg6local_fill_counters(rta, len,
SEG6_LOCAL_COUNTERS);
} else if (strcmp(*argv, "srh") == 0) { } else if (strcmp(*argv, "srh") == 0) {
NEXT_ARG(); NEXT_ARG();
if (srh_ok++) if (srh_ok++)
@ -1926,9 +1673,6 @@ int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp,
case LWTUNNEL_ENCAP_RPL: case LWTUNNEL_ENCAP_RPL:
ret = parse_encap_rpl(rta, len, &argc, &argv); ret = parse_encap_rpl(rta, len, &argc, &argv);
break; break;
case LWTUNNEL_ENCAP_IOAM6:
ret = parse_encap_ioam6(rta, len, &argc, &argv);
break;
default: default:
fprintf(stderr, "Error: unsupported encap type\n"); fprintf(stderr, "Error: unsupported encap type\n");
break; break;

View File

@ -34,10 +34,10 @@ static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: ip sr { COMMAND | help }\n" "Usage: ip sr { COMMAND | help }\n"
" ip sr hmac show\n" " ip sr hmac show\n"
" ip sr hmac set KEYID ALGO\n" " ip sr hmac set KEYID ALGO\n"
" ip sr tunsrc show\n" " ip sr tunsrc show\n"
" ip sr tunsrc set ADDRESS\n" " ip sr tunsrc set ADDRESS\n"
"where ALGO := { sha1 | sha256 }\n"); "where ALGO := { sha1 | sha256 }\n");
exit(-1); exit(-1);
} }

View File

@ -34,18 +34,18 @@ static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: ip tunnel { add | change | del | show | prl | 6rd } [ NAME ]\n" "Usage: ip tunnel { add | change | del | show | prl | 6rd } [ NAME ]\n"
" [ mode { gre | ipip | isatap | sit | vti } ]\n" " [ mode { gre | ipip | isatap | sit | vti } ]\n"
" [ remote ADDR ] [ local ADDR ]\n" " [ remote ADDR ] [ local ADDR ]\n"
" [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n" " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n"
" [ prl-default ADDR ] [ prl-nodefault ADDR ] [ prl-delete ADDR ]\n" " [ prl-default ADDR ] [ prl-nodefault ADDR ] [ prl-delete ADDR ]\n"
" [ 6rd-prefix ADDR ] [ 6rd-relay_prefix ADDR ] [ 6rd-reset ]\n" " [ 6rd-prefix ADDR ] [ 6rd-relay_prefix ADDR ] [ 6rd-reset ]\n"
" [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n" " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n"
"\n" "\n"
"Where: NAME := STRING\n" "Where: NAME := STRING\n"
" ADDR := { IP_ADDRESS | any }\n" " ADDR := { IP_ADDRESS | any }\n"
" TOS := { STRING | 00..ff | inherit | inherit/STRING | inherit/00..ff }\n" " TOS := { STRING | 00..ff | inherit | inherit/STRING | inherit/00..ff }\n"
" TTL := { 1..255 | inherit }\n" " TTL := { 1..255 | inherit }\n"
" KEY := { DOTTED_QUAD | NUMBER }\n"); " KEY := { DOTTED_QUAD | NUMBER }\n");
exit(-1); exit(-1);
} }

View File

@ -42,11 +42,11 @@ static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: ip tuntap { add | del | show | list | lst | help } [ dev PHYS_DEV ]\n" "Usage: ip tuntap { add | del | show | list | lst | help } [ dev PHYS_DEV ]\n"
" [ mode { tun | tap } ] [ user USER ] [ group GROUP ]\n" " [ mode { tun | tap } ] [ user USER ] [ group GROUP ]\n"
" [ one_queue ] [ pi ] [ vnet_hdr ] [ multi_queue ] [ name NAME ]\n" " [ one_queue ] [ pi ] [ vnet_hdr ] [ multi_queue ] [ name NAME ]\n"
"\n" "\n"
"Where: USER := { STRING | NUMBER }\n" "Where: USER := { STRING | NUMBER }\n"
" GROUP := { STRING | NUMBER }\n"); " GROUP := { STRING | NUMBER }\n");
exit(-1); exit(-1);
} }
@ -243,9 +243,6 @@ static void print_flags(long flags)
if (flags & IFF_ONE_QUEUE) if (flags & IFF_ONE_QUEUE)
print_string(PRINT_ANY, NULL, " %s", "one_queue"); print_string(PRINT_ANY, NULL, " %s", "one_queue");
if (flags & IFF_MULTI_QUEUE)
print_string(PRINT_ANY, NULL, " %s", "multi_queue");
if (flags & IFF_VNET_HDR) if (flags & IFF_VNET_HDR)
print_string(PRINT_ANY, NULL, " %s", "vnet_hdr"); print_string(PRINT_ANY, NULL, " %s", "vnet_hdr");
@ -256,14 +253,42 @@ static void print_flags(long flags)
print_string(PRINT_ANY, NULL, " %s", "filter"); print_string(PRINT_ANY, NULL, " %s", "filter");
flags &= ~(IFF_TUN | IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE | flags &= ~(IFF_TUN | IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE |
IFF_MULTI_QUEUE | IFF_VNET_HDR | IFF_PERSIST | IFF_VNET_HDR | IFF_PERSIST | IFF_NOFILTER);
IFF_NOFILTER);
if (flags) if (flags)
print_0xhex(PRINT_ANY, NULL, " %#llx", flags); print_0xhex(PRINT_ANY, NULL, "%#llx", flags);
close_json_array(PRINT_JSON, NULL); close_json_array(PRINT_JSON, NULL);
} }
static char *pid_name(pid_t pid)
{
char *comm;
FILE *f;
int err;
err = asprintf(&comm, "/proc/%d/comm", pid);
if (err < 0)
return NULL;
f = fopen(comm, "r");
free(comm);
if (!f) {
perror("fopen");
return NULL;
}
if (fscanf(f, "%ms\n", &comm) != 1) {
perror("fscanf");
comm = NULL;
}
if (fclose(f))
perror("fclose");
return comm;
}
static void show_processes(const char *name) static void show_processes(const char *name)
{ {
glob_t globbuf = { }; glob_t globbuf = { };
@ -321,7 +346,7 @@ static void show_processes(const char *name)
} else if (err == 2 && } else if (err == 2 &&
!strcmp("iff", key) && !strcmp("iff", key) &&
!strcmp(name, value)) { !strcmp(name, value)) {
char *pname = get_task_name(pid); char *pname = pid_name(pid);
print_string(PRINT_ANY, "name", print_string(PRINT_ANY, "name",
"%s", pname ? : "<NULL>"); "%s", pname ? : "<NULL>");

View File

@ -907,14 +907,6 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,
fprintf(fp, "if_id %#x", if_id); fprintf(fp, "if_id %#x", if_id);
fprintf(fp, "%s", _SL_); fprintf(fp, "%s", _SL_);
} }
if (tb[XFRMA_TFCPAD]) {
__u32 tfcpad = rta_getattr_u32(tb[XFRMA_TFCPAD]);
if (prefix)
fputs(prefix, fp);
fprintf(fp, "tfcpad %u", tfcpad);
fprintf(fp, "%s", _SL_);
}
} }
static int xfrm_selector_iszero(struct xfrm_selector *s) static int xfrm_selector_iszero(struct xfrm_selector *s)

View File

@ -442,6 +442,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (tb[IFLA_GRE_COLLECT_METADATA]) { if (tb[IFLA_GRE_COLLECT_METADATA]) {
print_bool(PRINT_ANY, "external", "external ", true); print_bool(PRINT_ANY, "external", "external ", true);
return;
} }
tnl_print_endpoint("remote", tb[IFLA_GRE_REMOTE], AF_INET); tnl_print_endpoint("remote", tb[IFLA_GRE_REMOTE], AF_INET);

View File

@ -461,6 +461,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (tb[IFLA_GRE_COLLECT_METADATA]) { if (tb[IFLA_GRE_COLLECT_METADATA]) {
print_bool(PRINT_ANY, "external", "external ", true); print_bool(PRINT_ANY, "external", "external ", true);
return;
} }
if (tb[IFLA_GRE_FLAGS]) if (tb[IFLA_GRE_FLAGS])

View File

@ -344,6 +344,7 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
if (tb[IFLA_IPTUN_COLLECT_METADATA]) { if (tb[IFLA_IPTUN_COLLECT_METADATA]) {
print_bool(PRINT_ANY, "external", "external ", true); print_bool(PRINT_ANY, "external", "external ", true);
return;
} }
if (tb[IFLA_IPTUN_FLAGS]) if (tb[IFLA_IPTUN_FLAGS])

View File

@ -368,6 +368,7 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
if (tb[IFLA_IPTUN_COLLECT_METADATA]) { if (tb[IFLA_IPTUN_COLLECT_METADATA]) {
print_bool(PRINT_ANY, "external", "external ", true); print_bool(PRINT_ANY, "external", "external ", true);
return;
} }
if (tb[IFLA_IPTUN_PROTO]) { if (tb[IFLA_IPTUN_PROTO]) {

View File

@ -1,53 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NH_COMMON_H__
#define __NH_COMMON_H__ 1
#include <list.h>
#define NH_CACHE_SIZE 1024
struct nha_res_grp {
__u16 buckets;
__u32 idle_timer;
__u32 unbalanced_timer;
__u64 unbalanced_time;
};
struct nh_entry {
struct hlist_node nh_hash;
__u32 nh_id;
__u32 nh_oif;
__u32 nh_flags;
__u16 nh_grp_type;
__u8 nh_family;
__u8 nh_scope;
__u8 nh_protocol;
bool nh_blackhole;
bool nh_fdb;
int nh_gateway_len;
union {
__be32 ipv4;
struct in6_addr ipv6;
} nh_gateway;
struct rtattr *nh_encap;
union {
struct rtattr rta;
__u8 _buf[RTA_LENGTH(sizeof(__u16))];
} nh_encap_type;
bool nh_has_res_grp;
struct nha_res_grp nh_res_grp;
int nh_groups_cnt;
struct nexthop_grp *nh_groups;
};
void print_cache_nexthop_id(FILE *fp, const char *fp_prefix, const char *jsobj,
__u32 nh_id);
int print_cache_nexthop(struct nlmsghdr *n, void *arg, bool process_cache);
#endif /* __NH_COMMON_H__ */

10
ip/routef Executable file
View File

@ -0,0 +1,10 @@
#! /bin/sh
# SPDX-License-Identifier: GPL-2.0
if [ -z "$*" ] ; then
exec ip -4 ro flush scope global type unicast
else
echo "Usage: routef"
echo
echo "This script will flush the IPv4 routing table"
fi

124
ip/routel
View File

@ -1,62 +1,72 @@
#! /usr/bin/env python3 #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
#
# Script created by: Stephen R. van den Berg <srb@cuci.nl>, 1999/04/18
# Donated to the public domain.
#
# This script transforms the output of "ip" into more readable text.
# "ip" is the Linux-advanced-routing configuration tool part of the
# iproute package.
# #
# This is simple script to process JSON output from ip route
# command and format it. Based on earlier shell script version.
"""Script to parse ip route output into more readable text."""
import sys test "X-h" = "X$1" && echo "Usage: $0 [tablenr [raw ip args...]]" && exit 64
import json
import getopt
import subprocess
test -z "$*" && set 0
def usage(): ip route list table "$@" |
'''Print usage and exit''' while read network rest
print("Usage: {} [tablenr [raw ip args...]]".format(sys.argv[0])) do set xx $rest
sys.exit(64) shift
proto=""
via=""
def main(): dev=""
'''Process the arguments''' scope=""
family = 'inet' src=""
try: table=""
opts, args = getopt.getopt(sys.argv[1:], "h46f:", ["help", "family="]) case $network in
except getopt.GetoptError as err: broadcast|local|unreachable) via=$network
print(err) network=$1
usage() shift
;;
for opt, arg in opts: esac
if opt in ["-h", "--help"]: while test $# != 0
usage() do
elif opt == '-6': case "$1" in
family = 'inet6' proto|via|dev|scope|src|table)
elif opt == "-4": key=$1
family = 'inet' val=$2
elif opt in ["-f", "--family"]: eval "$key='$val'"
family = arg shift 2
else: ;;
assert False, "unhandled option" dead|onlink|pervasive|offload|notify|linkdown|unresolved)
shift
if not args: ;;
args = ['0'] *)
# avoid infinite loop on unknown keyword without value at line end
cmd = ['ip', '-f', family, '-j', 'route', 'list', 'table'] + args shift
process = subprocess.Popen(cmd, stdout=subprocess.PIPE) shift
tbl = json.load(process.stdout) ;;
if family == 'inet': esac
fmt = '{:15} {:15} {:15} {:8} {:8}{:<16} {}' done
else: echo "$network $via $src $proto $scope $dev $table"
fmt = '{:32} {:32} {:32} {:8} {:8}{:<16} {}' done | awk -F ' ' '
BEGIN {
# ip route json keys format="%15s%-3s %15s %15s %8s %8s%7s %s\n";
keys = ['dst', 'gateway', 'prefsrc', 'protocol', 'scope', 'dev', 'table'] printf(format,"target","","gateway","source","proto","scope","dev","tbl");
print(fmt.format(*map(lambda x: x.capitalize(), keys))) }
{ network=$1;
for record in tbl: mask="";
fields = [record[k] if k in record else '' for k in keys] if(match(network,"/"))
print(fmt.format(*fields)) { mask=" "substr(network,RSTART+1);
network=substr(network,0,RSTART);
}
if __name__ == "__main__": via=$2;
main() src=$3;
proto=$4;
scope=$5;
dev=$6;
table=$7;
printf(format,network,mask,via,src,proto,scope,dev,table);
}
'

View File

@ -65,7 +65,7 @@ static void usage(void)
fprintf(stderr, fprintf(stderr,
"Usage: rtmon [ OPTIONS ] file FILE [ all | LISTofOBJECTS ]\n" "Usage: rtmon [ OPTIONS ] file FILE [ all | LISTofOBJECTS ]\n"
"OPTIONS := { -f[amily] { inet | inet6 | link | help } |\n" "OPTIONS := { -f[amily] { inet | inet6 | link | help } |\n"
" -4 | -6 | -0 | -V[ersion] }\n" " -4 | -6 | -0 | -V[ersion] }\n"
"LISTofOBJECTS := [ link ] [ address ] [ route ]\n"); "LISTofOBJECTS := [ link ] [ address ] [ route ]\n");
exit(-1); exit(-1);
} }

5
ip/rtpr Executable file
View File

@ -0,0 +1,5 @@
#! /bin/sh
# SPDX-License-Identifier: GPL-2.0
exec tr "[\\\\]" "[
]"

View File

@ -132,7 +132,6 @@ void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo,
void xfrm_policy_info_print(struct xfrm_userpolicy_info *xpinfo, void xfrm_policy_info_print(struct xfrm_userpolicy_info *xpinfo,
struct rtattr *tb[], FILE *fp, const char *prefix, struct rtattr *tb[], FILE *fp, const char *prefix,
const char *title); const char *title);
int xfrm_policy_default_print(struct nlmsghdr *n, FILE *fp);
int xfrm_id_parse(xfrm_address_t *saddr, struct xfrm_id *id, __u16 *family, int xfrm_id_parse(xfrm_address_t *saddr, struct xfrm_id *id, __u16 *family,
int loose, int *argcp, char ***argvp); int loose, int *argcp, char ***argvp);
int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp); int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp);

View File

@ -323,9 +323,6 @@ static int xfrm_accept_msg(struct rtnl_ctrl_data *ctrl,
case XFRM_MSG_MAPPING: case XFRM_MSG_MAPPING:
xfrm_mapping_print(n, arg); xfrm_mapping_print(n, arg);
return 0; return 0;
case XFRM_MSG_GETDEFAULT:
xfrm_policy_default_print(n, arg);
return 0;
default: default:
break; break;
} }

Some files were not shown because too many files have changed in this diff Show More