Merge branch 'main' into next

Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
David Ahern 2020-09-01 19:46:20 -06:00
commit 275eed9be5
8 changed files with 93 additions and 37 deletions

View File

@ -4654,6 +4654,7 @@ static int cmd_mon_show_cb(const struct nlmsghdr *nlh, void *data)
pr_out_trap_policer(dl, tb, false); pr_out_trap_policer(dl, tb, false);
break; break;
} }
fflush(stdout);
return MNL_CB_OK; return MNL_CB_OK;
} }

View File

@ -81,6 +81,12 @@ struct bpf_cgroup_storage_key {
__u32 attach_type; /* program attach type */ __u32 attach_type; /* program attach type */
}; };
union bpf_iter_link_info {
struct {
__u32 map_fd;
} map;
};
/* BPF syscall commands, see bpf(2) man-page for details. */ /* BPF syscall commands, see bpf(2) man-page for details. */
enum bpf_cmd { enum bpf_cmd {
BPF_MAP_CREATE, BPF_MAP_CREATE,
@ -117,6 +123,7 @@ enum bpf_cmd {
BPF_LINK_GET_NEXT_ID, BPF_LINK_GET_NEXT_ID,
BPF_ENABLE_STATS, BPF_ENABLE_STATS,
BPF_ITER_CREATE, BPF_ITER_CREATE,
BPF_LINK_DETACH,
}; };
enum bpf_map_type { enum bpf_map_type {
@ -230,6 +237,7 @@ enum bpf_attach_type {
BPF_CGROUP_INET_SOCK_RELEASE, BPF_CGROUP_INET_SOCK_RELEASE,
BPF_XDP_CPUMAP, BPF_XDP_CPUMAP,
BPF_SK_LOOKUP, BPF_SK_LOOKUP,
BPF_XDP,
__MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
}; };
@ -242,6 +250,7 @@ enum bpf_link_type {
BPF_LINK_TYPE_CGROUP = 3, BPF_LINK_TYPE_CGROUP = 3,
BPF_LINK_TYPE_ITER = 4, BPF_LINK_TYPE_ITER = 4,
BPF_LINK_TYPE_NETNS = 5, BPF_LINK_TYPE_NETNS = 5,
BPF_LINK_TYPE_XDP = 6,
MAX_BPF_LINK_TYPE, MAX_BPF_LINK_TYPE,
}; };
@ -607,9 +616,14 @@ union bpf_attr {
struct { /* struct used by BPF_LINK_CREATE command */ struct { /* struct used by BPF_LINK_CREATE command */
__u32 prog_fd; /* eBPF program to attach */ __u32 prog_fd; /* eBPF program to attach */
__u32 target_fd; /* object to attach to */ union {
__u32 target_fd; /* object to attach to */
__u32 target_ifindex; /* target ifindex */
};
__u32 attach_type; /* attach type */ __u32 attach_type; /* attach type */
__u32 flags; /* extra flags */ __u32 flags; /* extra flags */
__aligned_u64 iter_info; /* extra bpf_iter_link_info */
__u32 iter_info_len; /* iter_info length */
} link_create; } link_create;
struct { /* struct used by BPF_LINK_UPDATE command */ struct { /* struct used by BPF_LINK_UPDATE command */
@ -622,6 +636,10 @@ union bpf_attr {
__u32 old_prog_fd; __u32 old_prog_fd;
} link_update; } link_update;
struct {
__u32 link_fd;
} link_detach;
struct { /* struct used by BPF_ENABLE_STATS command */ struct { /* struct used by BPF_ENABLE_STATS command */
__u32 type; __u32 type;
} enable_stats; } enable_stats;
@ -3229,7 +3247,7 @@ union bpf_attr {
* Return * Return
* The id is returned or 0 in case the id could not be retrieved. * The id is returned or 0 in case the id could not be retrieved.
* *
* int bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags) * long bpf_ringbuf_output(void *ringbuf, void *data, u64 size, u64 flags)
* Description * Description
* Copy *size* bytes from *data* into a ring buffer *ringbuf*. * Copy *size* bytes from *data* into a ring buffer *ringbuf*.
* If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification
@ -4057,6 +4075,9 @@ struct bpf_link_info {
__u32 netns_ino; __u32 netns_ino;
__u32 attach_type; __u32 attach_type;
} netns; } netns;
struct {
__u32 ifindex;
} xdp;
}; };
} __attribute__((aligned(8))); } __attribute__((aligned(8)));

View File

@ -37,5 +37,4 @@ enum {
SEG6_IPTUN_MODE_L2ENCAP, SEG6_IPTUN_MODE_L2ENCAP,
}; };
#endif #endif

View File

@ -86,26 +86,26 @@ void iplink_usage(void)
" [ mtu MTU ]\n" " [ mtu MTU ]\n"
" [ netns { PID | NAME } ]\n" " [ netns { PID | NAME } ]\n"
" [ link-netns NAME | link-netnsid ID ]\n" " [ link-netns NAME | link-netnsid ID ]\n"
" [ alias NAME ]\n" " [ alias NAME ]\n"
" [ vf NUM [ mac LLADDR ]\n" " [ vf NUM [ mac LLADDR ]\n"
" [ vlan VLANID [ qos VLAN-QOS ] [ proto VLAN-PROTO ] ]\n" " [ vlan VLANID [ qos VLAN-QOS ] [ proto VLAN-PROTO ] ]\n"
" [ rate TXRATE ]\n" " [ rate TXRATE ]\n"
" [ max_tx_rate TXRATE ]\n" " [ max_tx_rate TXRATE ]\n"
" [ min_tx_rate TXRATE ]\n" " [ min_tx_rate TXRATE ]\n"
" [ spoofchk { on | off} ]\n" " [ spoofchk { on | off} ]\n"
" [ query_rss { on | off} ]\n" " [ query_rss { on | off} ]\n"
" [ state { auto | enable | disable} ] ]\n" " [ state { auto | enable | disable} ]\n"
" [ trust { on | off} ] ]\n" " [ trust { on | off} ]\n"
" [ node_guid { eui64 } ]\n" " [ node_guid EUI64 ]\n"
" [ port_guid { eui64 } ]\n" " [ port_guid EUI64 ] ]\n"
" [ { xdp | xdpgeneric | xdpdrv | xdpoffload } { off |\n" " [ { xdp | xdpgeneric | xdpdrv | xdpoffload } { off |\n"
" object FILE [ section NAME ] [ verbose ] |\n" " object FILE [ section NAME ] [ verbose ] |\n"
" pinned FILE } ]\n" " pinned FILE } ]\n"
" [ master DEVICE ][ vrf NAME ]\n" " [ master DEVICE ][ vrf NAME ]\n"
" [ nomaster ]\n" " [ nomaster ]\n"
" [ addrgenmode { eui64 | none | stable_secret | random } ]\n" " [ addrgenmode { eui64 | none | stable_secret | random } ]\n"
" [ protodown { on | off } ]\n" " [ protodown { on | off } ]\n"
" [ 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"
"\n" "\n"

View File

@ -25,7 +25,7 @@ static void print_usage(FILE *f)
{ {
fprintf(f, fprintf(f,
"Usage:\tip link add name NAME type hsr slave1 SLAVE1-IF slave2 SLAVE2-IF\n" "Usage:\tip link add name NAME type hsr slave1 SLAVE1-IF slave2 SLAVE2-IF\n"
"\t[ supervision ADDR-BYTE ] [version VERSION]\n" "\t[ supervision ADDR-BYTE ] [version VERSION] [proto PROTOCOL]\n"
"\n" "\n"
"NAME\n" "NAME\n"
" name of new hsr device (e.g. hsr0)\n" " name of new hsr device (e.g. hsr0)\n"
@ -35,7 +35,9 @@ static void print_usage(FILE *f)
" 0-255; the last byte of the multicast address used for HSR supervision\n" " 0-255; the last byte of the multicast address used for HSR supervision\n"
" frames (default = 0)\n" " frames (default = 0)\n"
"VERSION\n" "VERSION\n"
" 0,1; the protocol version to be used. (default = 0)\n"); " 0,1; the protocol version to be used. (default = 0)\n"
"PROTOCOL\n"
" 0 - HSR, 1 - PRP. (default = 0 - HSR)\n");
} }
static void usage(void) static void usage(void)
@ -49,6 +51,7 @@ static int hsr_parse_opt(struct link_util *lu, int argc, char **argv,
int ifindex; int ifindex;
unsigned char multicast_spec; unsigned char multicast_spec;
unsigned char protocol_version; unsigned char protocol_version;
unsigned char protocol = HSR_PROTOCOL_HSR;
while (argc > 0) { while (argc > 0) {
if (matches(*argv, "supervision") == 0) { if (matches(*argv, "supervision") == 0) {
@ -64,6 +67,13 @@ static int hsr_parse_opt(struct link_util *lu, int argc, char **argv,
invarg("version is invalid", *argv); invarg("version is invalid", *argv);
addattr_l(n, 1024, IFLA_HSR_VERSION, addattr_l(n, 1024, IFLA_HSR_VERSION,
&protocol_version, 1); &protocol_version, 1);
} else if (matches(*argv, "proto") == 0) {
NEXT_ARG();
if (!(get_u8(&protocol, *argv, 0) == HSR_PROTOCOL_HSR ||
get_u8(&protocol, *argv, 0) == HSR_PROTOCOL_PRP))
invarg("protocol is invalid", *argv);
addattr_l(n, 1024, IFLA_HSR_PROTOCOL,
&protocol, 1);
} else if (matches(*argv, "slave1") == 0) { } else if (matches(*argv, "slave1") == 0) {
NEXT_ARG(); NEXT_ARG();
ifindex = ll_name_to_index(*argv); ifindex = ll_name_to_index(*argv);
@ -140,6 +150,9 @@ static void hsr_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]), RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]),
ARPHRD_VOID, ARPHRD_VOID,
b1, sizeof(b1))); b1, sizeof(b1)));
if (tb[IFLA_HSR_PROTOCOL])
print_hhu(PRINT_ANY, "proto", "proto %hhu ",
rta_getattr_u8(tb[IFLA_HSR_PROTOCOL]));
} }
static void hsr_print_help(struct link_util *lu, int argc, char **argv, static void hsr_print_help(struct link_util *lu, int argc, char **argv,

View File

@ -291,7 +291,7 @@ static int multiaddr_modify(int cmd, int argc, char **argv)
{ {
struct ifreq ifr = {}; struct ifreq ifr = {};
int family; int family;
int fd; int fd, len;
if (cmd == RTM_NEWADDR) if (cmd == RTM_NEWADDR)
cmd = SIOCADDMULTI; cmd = SIOCADDMULTI;
@ -313,9 +313,14 @@ static int multiaddr_modify(int cmd, int argc, char **argv)
usage(); usage();
if (ifr.ifr_hwaddr.sa_data[0]) if (ifr.ifr_hwaddr.sa_data[0])
duparg("address", *argv); duparg("address", *argv);
if (ll_addr_a2n(ifr.ifr_hwaddr.sa_data, len = ll_addr_a2n(ifr.ifr_hwaddr.sa_data,
14, *argv) < 0) { sizeof(ifr.ifr_hwaddr.sa_data),
fprintf(stderr, "Error: \"%s\" is not a legal ll address.\n", *argv); *argv);
if (len < 0)
exit(1);
if (len != ETH_ALEN) {
fprintf(stderr, "Error: Invalid address length %d - must be %d bytes\n", len, ETH_ALEN);
exit(1); exit(1);
} }
} }

View File

@ -1404,7 +1404,8 @@ the following additional arguments are supported:
.BI slave1 " SLAVE1-IF " slave2 " SLAVE2-IF " .BI slave1 " SLAVE1-IF " slave2 " SLAVE2-IF "
.RB [ " supervision" .RB [ " supervision"
.IR ADDR-BYTE " ] [" .IR ADDR-BYTE " ] ["
.BR version " { " 0 " | " 1 " } ]" .BR version " { " 0 " | " 1 " } ["
.BR proto " { " 0 " | " 1 " } ]"
.in +8 .in +8
.sp .sp
@ -1425,6 +1426,12 @@ Default option is "0", possible values 0-255.
- Selects the protocol version of the interface. Default option is "0", which - Selects the protocol version of the interface. Default option is "0", which
corresponds to the 2010 version of the HSR standard. Option "1" activates the corresponds to the 2010 version of the HSR standard. Option "1" activates the
2012 version. 2012 version.
.BR proto " { " 0 " | " 1 " }"
- Selects the protocol at the interface. Default option is "0", which
corresponds to the HSR standard. Option "1" activates the Parallel
Redundancy Protocol (PRP).
.
.in -8 .in -8
.TP .TP

View File

@ -157,26 +157,36 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line)
if (!str) if (!str)
return; return;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) if (nla_line[RDMA_NLDEV_ATTR_RES_PID] || rd->json_output)
snprintf(tmp, sizeof(tmp), "%s", str); snprintf(tmp, sizeof(tmp), "%s", str);
else else
snprintf(tmp, sizeof(tmp), "[%s]", str); snprintf(tmp, sizeof(tmp), "[%s]", str);
print_color_string(PRINT_ANY, COLOR_NONE, "comm", "comm %s ", str); print_color_string(PRINT_ANY, COLOR_NONE, "comm", "comm %s ", tmp);
} }
void print_dev(struct rd *rd, uint32_t idx, const char *name) void print_dev(struct rd *rd, uint32_t idx, const char *name)
{ {
print_color_int(PRINT_ANY, COLOR_NONE, "ifindex", "ifindex %d ", idx); print_color_int(PRINT_ANY, COLOR_NONE, "ifindex", NULL, idx);
print_color_string(PRINT_ANY, COLOR_NONE, "ifname", "ifname %s ", name); print_color_string(PRINT_ANY, COLOR_NONE, "ifname", "dev %s ", name);
} }
void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port, void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port,
struct nlattr **nla_line) struct nlattr **nla_line)
{ {
char tmp[64] = {};
print_color_uint(PRINT_JSON, COLOR_NONE, "ifindex", NULL, idx); print_color_uint(PRINT_JSON, COLOR_NONE, "ifindex", NULL, idx);
print_color_string(PRINT_ANY, COLOR_NONE, "ifname", "link %s/", name); print_color_string(PRINT_ANY, COLOR_NONE, "ifname", NULL, name);
if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX]) if (nla_line[RDMA_NLDEV_ATTR_PORT_INDEX]) {
print_color_uint(PRINT_ANY, COLOR_NONE, "port", "%u ", port); print_color_uint(PRINT_ANY, COLOR_NONE, "port", NULL, port);
snprintf(tmp, sizeof(tmp), "%s/%d", name, port);
} else {
snprintf(tmp, sizeof(tmp), "%s/-", name);
}
if (!rd->json_output)
print_color_string(PRINT_ANY, COLOR_NONE, NULL, "link %s ",
tmp);
} }
void print_qp_type(struct rd *rd, uint32_t val) void print_qp_type(struct rd *rd, uint32_t val)