Merge ../iproute2-next

This commit is contained in:
Stephen Hemminger 2018-06-08 10:27:04 -07:00
commit 17678d3059
42 changed files with 2691 additions and 494 deletions

View File

@ -1693,6 +1693,20 @@ static const char *port_type_name(uint32_t type)
}
}
static const char *port_flavour_name(uint16_t flavour)
{
switch (flavour) {
case DEVLINK_PORT_FLAVOUR_PHYSICAL:
return "physical";
case DEVLINK_PORT_FLAVOUR_CPU:
return "cpu";
case DEVLINK_PORT_FLAVOUR_DSA:
return "dsa";
default:
return "<unknown flavour>";
}
}
static void pr_out_port(struct dl *dl, struct nlattr **tb)
{
struct nlattr *pt_attr = tb[DEVLINK_ATTR_PORT_TYPE];
@ -1717,6 +1731,12 @@ static void pr_out_port(struct dl *dl, struct nlattr **tb)
if (tb[DEVLINK_ATTR_PORT_IBDEV_NAME])
pr_out_str(dl, "ibdev",
mnl_attr_get_str(tb[DEVLINK_ATTR_PORT_IBDEV_NAME]));
if (tb[DEVLINK_ATTR_PORT_FLAVOUR]) {
uint16_t port_flavour =
mnl_attr_get_u16(tb[DEVLINK_ATTR_PORT_FLAVOUR]);
pr_out_str(dl, "flavour", port_flavour_name(port_flavour));
}
if (tb[DEVLINK_ATTR_PORT_SPLIT_GROUP])
pr_out_uint(dl, "split_group",
mnl_attr_get_u32(tb[DEVLINK_ATTR_PORT_SPLIT_GROUP]));

File diff suppressed because it is too large Load Diff

View File

@ -132,6 +132,16 @@ enum devlink_eswitch_encap_mode {
DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
};
enum devlink_port_flavour {
DEVLINK_PORT_FLAVOUR_PHYSICAL, /* Any kind of a port physically
* facing the user.
*/
DEVLINK_PORT_FLAVOUR_CPU, /* CPU port */
DEVLINK_PORT_FLAVOUR_DSA, /* Distributed switch architecture
* interconnect port.
*/
};
enum devlink_attr {
/* don't change the order or add anything between, this is ABI! */
DEVLINK_ATTR_UNSPEC,
@ -224,6 +234,10 @@ enum devlink_attr {
DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID, /* u64 */
DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,/* u64 */
DEVLINK_ATTR_PORT_FLAVOUR, /* u16 */
DEVLINK_ATTR_PORT_NUMBER, /* u32 */
DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER, /* u32 */
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,

View File

@ -33,6 +33,7 @@ enum {
IFA_CACHEINFO,
IFA_MULTICAST,
IFA_FLAGS,
IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
__IFA_MAX,
};

View File

@ -331,6 +331,7 @@ enum {
IFLA_BRPORT_BCAST_FLOOD,
IFLA_BRPORT_GROUP_FWD_MASK,
IFLA_BRPORT_NEIGH_SUPPRESS,
IFLA_BRPORT_ISOLATED,
__IFLA_BRPORT_MAX
};
#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
@ -514,6 +515,7 @@ enum {
IFLA_VXLAN_COLLECT_METADATA,
IFLA_VXLAN_LABEL,
IFLA_VXLAN_GPE,
IFLA_VXLAN_TTL_INHERIT,
__IFLA_VXLAN_MAX
};
#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)

View File

@ -129,6 +129,7 @@ enum {
#define TCA_CLS_FLAGS_SKIP_SW (1 << 1) /* don't use filter in SW */
#define TCA_CLS_FLAGS_IN_HW (1 << 2) /* filter is offloaded to HW */
#define TCA_CLS_FLAGS_NOT_IN_HW (1 << 3) /* filter isn't offloaded to HW */
#define TCA_CLS_FLAGS_VERBOSE (1 << 4) /* verbose logging */
/* U32 filters */

View File

@ -327,6 +327,9 @@ enum rtattr_type_t {
RTA_PAD,
RTA_UID,
RTA_TTL_PROPAGATE,
RTA_IP_PROTO,
RTA_SPORT,
RTA_DPORT,
__RTA_MAX
};

View File

@ -25,6 +25,7 @@ enum {
SEG6_LOCAL_NH6,
SEG6_LOCAL_IIF,
SEG6_LOCAL_OIF,
SEG6_LOCAL_BPF,
__SEG6_LOCAL_MAX,
};
#define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1)
@ -59,10 +60,21 @@ enum {
SEG6_LOCAL_ACTION_END_AS = 13,
/* forward to SR-unaware VNF with masquerading */
SEG6_LOCAL_ACTION_END_AM = 14,
/* custom BPF action */
SEG6_LOCAL_ACTION_END_BPF = 15,
__SEG6_LOCAL_ACTION_MAX,
};
#define SEG6_LOCAL_ACTION_MAX (__SEG6_LOCAL_ACTION_MAX - 1)
enum {
SEG6_LOCAL_BPF_PROG_UNSPEC,
SEG6_LOCAL_BPF_PROG,
SEG6_LOCAL_BPF_PROG_NAME,
__SEG6_LOCAL_BPF_PROG_MAX,
};
#define SEG6_LOCAL_BPF_PROG_MAX (__SEG6_LOCAL_BPF_PROG_MAX - 1)
#endif

View File

@ -122,6 +122,10 @@ enum {
#define TCP_MD5SIG_EXT 32 /* TCP MD5 Signature with extensions */
#define TCP_FASTOPEN_KEY 33 /* Set the key for Fast Open (cookie) */
#define TCP_FASTOPEN_NO_COOKIE 34 /* Enable TFO without a TFO cookie */
#define TCP_ZEROCOPY_RECEIVE 35
#define TCP_INQ 36 /* Notify bytes available to read as a cmsg on read */
#define TCP_CM_INQ TCP_INQ
struct tcp_repair_opt {
__u32 opt_code;
@ -224,6 +228,9 @@ struct tcp_info {
__u64 tcpi_busy_time; /* Time (usec) busy sending data */
__u64 tcpi_rwnd_limited; /* Time (usec) limited by receive window */
__u64 tcpi_sndbuf_limited; /* Time (usec) limited by send buffer */
__u32 tcpi_delivered;
__u32 tcpi_delivered_ce;
};
/* netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */
@ -244,6 +251,8 @@ enum {
TCP_NLA_SNDQ_SIZE, /* Data (bytes) pending in send queue */
TCP_NLA_CA_STATE, /* ca_state of socket */
TCP_NLA_SND_SSTHRESH, /* Slow start size threshold */
TCP_NLA_DELIVERED, /* Data pkts delivered incl. out-of-order */
TCP_NLA_DELIVERED_CE, /* Like above but only ones w/ CE marks */
};
@ -271,4 +280,11 @@ struct tcp_diag_md5sig {
__u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN];
};
/* setsockopt(fd, IPPROTO_TCP, TCP_ZEROCOPY_RECEIVE, ...) */
struct tcp_zerocopy_receive {
__u64 address; /* in: address of mapping */
__u32 length; /* in/out: number of bytes to map/mapped */
__u32 recv_skip_hint; /* out: amount of bytes to skip */
};
#endif /* _LINUX_TCP_H */

View File

@ -209,16 +209,16 @@ struct tipc_group_req {
* The string formatting for each name element is:
* media: media
* interface: media:interface name
* link: Z.C.N:interface-Z.C.N:interface
*
* link: node:interface-node:interface
*/
#define TIPC_NODEID_LEN 16
#define TIPC_MAX_MEDIA_NAME 16
#define TIPC_MAX_IF_NAME 16
#define TIPC_MAX_BEARER_NAME 32
#define TIPC_MAX_LINK_NAME 68
#define SIOCGETLINKNAME SIOCPROTOPRIVATE
#define SIOCGETLINKNAME SIOCPROTOPRIVATE
#define SIOCGETNODEID (SIOCPROTOPRIVATE + 1)
struct tipc_sioc_ln_req {
__u32 peer;
@ -226,6 +226,10 @@ struct tipc_sioc_ln_req {
char linkname[TIPC_MAX_LINK_NAME];
};
struct tipc_sioc_nodeid_req {
__u32 peer;
char node_id[TIPC_NODEID_LEN];
};
/* The macros and functions below are deprecated:
*/

View File

@ -266,6 +266,7 @@ enum {
TIPC_NLA_PROP_PRIO, /* u32 */
TIPC_NLA_PROP_TOL, /* u32 */
TIPC_NLA_PROP_WIN, /* u32 */
TIPC_NLA_PROP_MTU, /* u32 */
__TIPC_NLA_PROP_MAX,
TIPC_NLA_PROP_MAX = __TIPC_NLA_PROP_MAX - 1

View File

@ -63,7 +63,7 @@ static void usage(void)
fprintf(stderr, " ip address {showdump|restore}\n");
fprintf(stderr, "IFADDR := PREFIX | ADDR peer PREFIX\n");
fprintf(stderr, " [ broadcast ADDR ] [ anycast ADDR ]\n");
fprintf(stderr, " [ label IFNAME ] [ scope SCOPE-ID ]\n");
fprintf(stderr, " [ label IFNAME ] [ scope SCOPE-ID ] [ metric METRIC ]\n");
fprintf(stderr, "SCOPE-ID := [ host | link | global | NUMBER ]\n");
fprintf(stderr, "FLAG-LIST := [ FLAG-LIST ] FLAG\n");
fprintf(stderr, "FLAG := [ permanent | dynamic | secondary | primary |\n");
@ -1349,6 +1349,10 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
rta_tb[IFA_ADDRESS]));
}
print_int(PRINT_ANY, "prefixlen", "/%d ", ifa->ifa_prefixlen);
if (rta_tb[IFA_RT_PRIORITY])
print_uint(PRINT_ANY, "metric", "metric %u ",
rta_getattr_u32(rta_tb[IFA_RT_PRIORITY]));
}
if (brief)
@ -2146,6 +2150,15 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
NEXT_ARG();
l = *argv;
addattr_l(&req.n, sizeof(req), IFA_LABEL, l, strlen(l)+1);
} else if (matches(*argv, "metric") == 0 ||
matches(*argv, "priority") == 0 ||
matches(*argv, "preference") == 0) {
__u32 metric;
NEXT_ARG();
if (get_u32(&metric, *argv, 0))
invarg("\"metric\" value is invalid\n", *argv);
addattr32(&req.n, sizeof(req), IFA_RT_PRIORITY, metric);
} else if (matches(*argv, "valid_lft") == 0) {
if (valid_lftp)
duparg("valid_lft", *argv);

View File

@ -51,7 +51,7 @@ static void print_explain(FILE *f)
"Where: VNI := 0-16777215\n"
" ADDR := { IP_ADDRESS | any }\n"
" TOS := { NUMBER | inherit }\n"
" TTL := { 1..255 | inherit }\n"
" TTL := { 1..255 | auto | inherit }\n"
" LABEL := 0-1048575\n"
);
}
@ -143,14 +143,18 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
NEXT_ARG();
check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
if (strcmp(*argv, "inherit") != 0) {
if (strcmp(*argv, "inherit") == 0) {
addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
} else if (strcmp(*argv, "auto") == 0) {
addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
} else {
if (get_unsigned(&uval, *argv, 0))
invarg("invalid TTL", *argv);
if (uval > 255)
invarg("TTL must be <= 255", *argv);
ttl = uval;
addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
}
addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
} else if (!matches(*argv, "tos") ||
!matches(*argv, "dsfield")) {
__u32 uval;

View File

@ -69,7 +69,8 @@ static void usage(void)
" [ from ADDRESS iif STRING ]\n"
" [ oif STRING ] [ tos TOS ]\n"
" [ mark NUMBER ] [ vrf NAME ]\n"
" [ uid NUMBER ]\n"
" [ uid NUMBER ] [ ipproto PROTOCOL ]\n"
" [ sport NUMBER ] [ dport NUMBER ]\n"
" ip route { add | del | change | append | replace } ROUTE\n"
"SELECTOR := [ root PREFIX ] [ match PREFIX ] [ exact PREFIX ]\n"
" [ table TABLE_ID ] [ vrf NAME ] [ proto RTPROTO ]\n"
@ -899,17 +900,14 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
rta_getattr_u32(tb[RTA_UID]));
if (r->rtm_family == AF_INET) {
if (r->rtm_flags & RTM_F_CLONED) {
if (r->rtm_flags & RTM_F_CLONED)
print_cache_flags(fp, r->rtm_flags);
if (tb[RTA_CACHEINFO])
print_rta_cacheinfo(fp, RTA_DATA(tb[RTA_CACHEINFO]));
}
if (tb[RTA_CACHEINFO])
print_rta_cacheinfo(fp, RTA_DATA(tb[RTA_CACHEINFO]));
} else if (r->rtm_family == AF_INET6) {
if (r->rtm_flags & RTM_F_CLONED) {
if (tb[RTA_CACHEINFO])
print_rta_cacheinfo(fp, RTA_DATA(tb[RTA_CACHEINFO]));
}
if (tb[RTA_CACHEINFO])
print_rta_cacheinfo(fp, RTA_DATA(tb[RTA_CACHEINFO]));
}
if (tb[RTA_METRICS])
@ -1994,6 +1992,29 @@ static int iproute_get(int argc, char **argv)
req.r.rtm_family = addr.family;
addattr_l(&req.n, sizeof(req), RTA_NEWDST,
&addr.data, addr.bytelen);
} else if (matches(*argv, "sport") == 0) {
__be16 sport;
NEXT_ARG();
if (get_be16(&sport, *argv, 0))
invarg("invalid sport\n", *argv);
addattr16(&req.n, sizeof(req), RTA_SPORT, sport);
} else if (matches(*argv, "dport") == 0) {
__be16 dport;
NEXT_ARG();
if (get_be16(&dport, *argv, 0))
invarg("invalid dport\n", *argv);
addattr16(&req.n, sizeof(req), RTA_DPORT, dport);
} else if (matches(*argv, "ipproto") == 0) {
int ipproto;
NEXT_ARG();
ipproto = inet_proto_a2n(*argv);
if (ipproto < 0)
invarg("Invalid \"ipproto\" value\n",
*argv);
addattr8(&req.n, sizeof(req), RTA_IP_PROTO, ipproto);
} else {
inet_prefix addr;

View File

@ -31,9 +31,9 @@ static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
);
fprintf(f,
" [ local ADDR ]\n"
" [ [i|o]seq ]\n"
" [ [i|o]key KEY ]\n"
" [ [i|o]csum ]\n"
" [ [no][i|o]seq ]\n"
" [ [i|o]key KEY | no[i|o]key ]\n"
" [ [no][i|o]csum ]\n"
" [ ttl TTL ]\n"
" [ tos TOS ]\n"
" [ [no]pmtudisc ]\n"
@ -210,28 +210,52 @@ get_failed:
iflags |= GRE_KEY;
oflags |= GRE_KEY;
ikey = okey = tnl_parse_key("key", *argv);
} else if (!matches(*argv, "nokey")) {
iflags &= ~GRE_KEY;
oflags &= ~GRE_KEY;
ikey = okey = 0;
} else if (!matches(*argv, "ikey")) {
NEXT_ARG();
iflags |= GRE_KEY;
ikey = tnl_parse_key("ikey", *argv);
} else if (!matches(*argv, "noikey")) {
iflags &= ~GRE_KEY;
ikey = 0;
} else if (!matches(*argv, "okey")) {
NEXT_ARG();
oflags |= GRE_KEY;
okey = tnl_parse_key("okey", *argv);
} else if (!matches(*argv, "nookey")) {
oflags &= ~GRE_KEY;
okey = 0;
} else if (!matches(*argv, "seq")) {
iflags |= GRE_SEQ;
oflags |= GRE_SEQ;
} else if (!matches(*argv, "noseq")) {
iflags &= ~GRE_SEQ;
oflags &= ~GRE_SEQ;
} else if (!matches(*argv, "iseq")) {
iflags |= GRE_SEQ;
} else if (!matches(*argv, "noiseq")) {
iflags &= ~GRE_SEQ;
} else if (!matches(*argv, "oseq")) {
oflags |= GRE_SEQ;
} else if (!matches(*argv, "nooseq")) {
oflags &= ~GRE_SEQ;
} else if (!matches(*argv, "csum")) {
iflags |= GRE_CSUM;
oflags |= GRE_CSUM;
} else if (!matches(*argv, "nocsum")) {
iflags &= ~GRE_CSUM;
oflags &= ~GRE_CSUM;
} else if (!matches(*argv, "icsum")) {
iflags |= GRE_CSUM;
} else if (!matches(*argv, "noicsum")) {
iflags &= ~GRE_CSUM;
} else if (!matches(*argv, "ocsum")) {
oflags |= GRE_CSUM;
} else if (!matches(*argv, "noocsum")) {
oflags &= ~GRE_CSUM;
} else if (!matches(*argv, "nopmtudisc")) {
pmtudisc = 0;
} else if (!matches(*argv, "pmtudisc")) {

View File

@ -38,9 +38,9 @@ static void gre_print_help(struct link_util *lu, int argc, char **argv, FILE *f)
);
fprintf(f,
" [ local ADDR ]\n"
" [ [i|o]seq ]\n"
" [ [i|o]key KEY ]\n"
" [ [i|o]csum ]\n"
" [ [no][i|o]seq ]\n"
" [ [i|o]key KEY | no[i|o]key ]\n"
" [ [no][i|o]csum ]\n"
" [ hoplimit TTL ]\n"
" [ encaplimit ELIM ]\n"
" [ tclass TCLASS ]\n"
@ -220,28 +220,52 @@ get_failed:
iflags |= GRE_KEY;
oflags |= GRE_KEY;
ikey = okey = tnl_parse_key("key", *argv);
} else if (!matches(*argv, "nokey")) {
iflags &= ~GRE_KEY;
oflags &= ~GRE_KEY;
ikey = okey = 0;
} else if (!matches(*argv, "ikey")) {
NEXT_ARG();
iflags |= GRE_KEY;
ikey = tnl_parse_key("ikey", *argv);
} else if (!matches(*argv, "noikey")) {
iflags &= ~GRE_KEY;
ikey = 0;
} else if (!matches(*argv, "okey")) {
NEXT_ARG();
oflags |= GRE_KEY;
okey = tnl_parse_key("okey", *argv);
} else if (!matches(*argv, "nookey")) {
oflags &= ~GRE_KEY;
okey = 0;
} else if (!matches(*argv, "seq")) {
iflags |= GRE_SEQ;
oflags |= GRE_SEQ;
} else if (!matches(*argv, "noseq")) {
iflags &= ~GRE_SEQ;
oflags &= ~GRE_SEQ;
} else if (!matches(*argv, "iseq")) {
iflags |= GRE_SEQ;
} else if (!matches(*argv, "noiseq")) {
iflags &= ~GRE_SEQ;
} else if (!matches(*argv, "oseq")) {
oflags |= GRE_SEQ;
} else if (!matches(*argv, "nooseq")) {
oflags &= ~GRE_SEQ;
} else if (!matches(*argv, "csum")) {
iflags |= GRE_CSUM;
oflags |= GRE_CSUM;
} else if (!matches(*argv, "nocsum")) {
iflags &= ~GRE_CSUM;
oflags &= ~GRE_CSUM;
} else if (!matches(*argv, "icsum")) {
iflags |= GRE_CSUM;
} else if (!matches(*argv, "noicsum")) {
iflags &= ~GRE_CSUM;
} else if (!matches(*argv, "ocsum")) {
oflags |= GRE_CSUM;
} else if (!matches(*argv, "noocsum")) {
oflags &= ~GRE_CSUM;
} else if (!matches(*argv, "remote")) {
NEXT_ARG();
get_addr(&daddr, *argv, AF_INET6);

View File

@ -97,6 +97,11 @@ static const struct bpf_prog_meta __bpf_prog_meta[] = {
},
};
static bool bpf_map_offload_neutral(enum bpf_map_type type)
{
return type == BPF_MAP_TYPE_PERF_EVENT_ARRAY;
}
static const char *bpf_prog_to_subdir(enum bpf_prog_type type)
{
assert(type < ARRAY_SIZE(__bpf_prog_meta) &&
@ -1594,7 +1599,7 @@ static int bpf_map_attach(const char *name, struct bpf_elf_ctx *ctx,
const struct bpf_elf_map *map, struct bpf_map_ext *ext,
int *have_map_in_map)
{
int fd, ret, map_inner_fd = 0;
int fd, ifindex, ret, map_inner_fd = 0;
fd = bpf_probe_pinned(name, ctx, map->pinning);
if (fd > 0) {
@ -1631,10 +1636,10 @@ static int bpf_map_attach(const char *name, struct bpf_elf_ctx *ctx,
}
}
ifindex = bpf_map_offload_neutral(map->type) ? 0 : ctx->ifindex;
errno = 0;
fd = bpf_map_create(map->type, map->size_key, map->size_value,
map->max_elem, map->flags, map_inner_fd,
ctx->ifindex);
map->max_elem, map->flags, map_inner_fd, ifindex);
if (fd < 0 || ctx->verbose) {
bpf_map_report(fd, name, map, ctx, map_inner_fd);

View File

@ -27,6 +27,8 @@ ip-address \- protocol address management
.IR IFNAME " ] [ "
.B scope
.IR SCOPE-ID " ] [ "
.B metric
.IR METRIC " ] [ "
.B to
.IR PREFIX " ] [ " FLAG-LIST " ] [ "
.B label
@ -214,6 +216,10 @@ valid inside this site.
- the address is valid only inside this host.
.in -8
.TP
.BI metric " NUMBER"
priority of prefix route associated with address.
.TP
.BI valid_lft " LFT"
the valid lifetime of this address; see section 5.5.4 of

View File

@ -693,13 +693,13 @@ tunnel.
.in -8
.TP
GRE, IPIP, SIT Type Support
For a link of types
.I GRE/IPIP/SIT
IPIP, SIT Type Support
For a link of type
.IR IPIP or SIT
the following additional arguments are supported:
.BI "ip link add " DEVICE
.BR type " { " gre " | " ipip " | " sit " }"
.BR type " { " ipip " | " sit " }"
.BI " remote " ADDR " local " ADDR
[
.BR encap " { " fou " | " gue " | " none " }"
@ -764,6 +764,154 @@ IPv6-Over-IPv4 is not supported for IPIP.
- make this tunnel externally controlled
.RB "(e.g. " "ip route encap" ).
.in -8
.TP
GRE Type Support
For a link of type
.IR GRE " or " GRETAP
the following additional arguments are supported:
.BI "ip link add " DEVICE
.BR type " { " gre " | " gretap " }"
.BI " remote " ADDR " local " ADDR
[
.RB [ no ] "" [ i | o ] seq
] [
.RB [ i | o ] key
.I KEY
|
.BR no [ i | o ] key
] [
.RB [ no ] "" [ i | o ] csum
] [
.BI ttl " TTL "
] [
.BI tos " TOS "
] [
.RB [ no ] pmtudisc
] [
.RB [ no ] ignore-df
] [
.BI dev " PHYS_DEV "
] [
.BR encap " { " fou " | " gue " | " none " }"
] [
.BR encap-sport " { " \fIPORT " | " auto " }"
] [
.BI "encap-dport " PORT
] [
.RB [ no ] encap-csum
] [
.RB [ no ] encap-remcsum
] [
.BR external
]
.in +8
.sp
.BI remote " ADDR "
- specifies the remote address of the tunnel.
.sp
.BI local " ADDR "
- specifies the fixed local address for tunneled packets.
It must be an address on another interface on this host.
.sp
.RB [ no ] "" [ i | o ] seq
- serialize packets.
The
.B oseq
flag enables sequencing of outgoing packets.
The
.B iseq
flag requires that all input packets are serialized.
.sp
.RB [ i | o ] key
.I KEY
|
.BR no [ i | o ] key
- use keyed GRE with key
.IR KEY ". "KEY
is either a number or an IPv4 address-like dotted quad.
The
.B key
parameter specifies the same key to use in both directions.
The
.BR ikey " and " okey
parameters specify different keys for input and output.
.sp
.RB [ no ] "" [ i | o ] csum
- generate/require checksums for tunneled packets.
The
.B ocsum
flag calculates checksums for outgoing packets.
The
.B icsum
flag requires that all input packets have the correct
checksum. The
.B csum
flag is equivalent to the combination
.B "icsum ocsum" .
.sp
.BI ttl " TTL"
- specifies the TTL value to use in outgoing packets.
.sp
.BI tos " TOS"
- specifies the TOS value to use in outgoing packets.
.sp
.RB [ no ] pmtudisc
- enables/disables Path MTU Discovery on this tunnel.
It is enabled by default. Note that a fixed ttl is incompatible
with this option: tunneling with a fixed ttl always makes pmtu
discovery.
.sp
.RB [ no ] ignore-df
- enables/disables IPv4 DF suppression on this tunnel.
Normally datagrams that exceed the MTU will be fragmented; the presence
of the DF flag inhibits this, resulting instead in an ICMP Unreachable
(Fragmentation Required) message. Enabling this attribute casues the
DF flag to be ignored.
.sp
.BI dev " PHYS_DEV"
- specifies the physical device to use for tunnel endpoint communication.
.sp
.BR encap " { " fou " | " gue " | " none " }"
- specifies type of secondary UDP encapsulation. "fou" indicates
Foo-Over-UDP, "gue" indicates Generic UDP Encapsulation.
.sp
.BR encap-sport " { " \fIPORT " | " auto " }"
- specifies the source port in UDP encapsulation.
.IR PORT
indicates the port by number, "auto"
indicates that the port number should be chosen automatically
(the kernel picks a flow based on the flow hash of the
encapsulated packet).
.sp
.RB [ no ] encap-csum
- specifies if UDP checksums are enabled in the secondary
encapsulation.
.sp
.RB [ no ] encap-remcsum
- specifies if Remote Checksum Offload is enabled. This is only
applicable for Generic UDP Encapsulation.
.sp
.BR external
- make this tunnel externally controlled
.RB "(e.g. " "ip route encap" ).
.in -8
.TP
@ -776,12 +924,14 @@ the following additional arguments are supported:
.BR type " { " ip6gre " | " ip6gretap " }"
.BI remote " ADDR " local " ADDR"
[
.RB [ i | o ] seq
.RB [ no ] "" [ i | o ] seq
] [
.RB [ i | o ] key
.I KEY
|
.BR no [ i | o ] key
] [
.RB [ i | o ] csum
.RB [ no ] "" [ i | o ] csum
] [
.BI hoplimit " TTL "
] [
@ -811,7 +961,7 @@ the following additional arguments are supported:
It must be an address on another interface on this host.
.sp
.RB [ i | o ] seq
.RB [ no ] "" [ i | o ] seq
- serialize packets.
The
.B oseq
@ -821,7 +971,10 @@ The
flag requires that all input packets are serialized.
.sp
.RB [ i | o ] key " \fIKEY"
.RB [ i | o ] key
.I KEY
|
.BR no [ i | o ] key
- use keyed GRE with key
.IR KEY ". "KEY
is either a number or an IPv4 address-like dotted quad.
@ -833,7 +986,7 @@ The
parameters specify different keys for input and output.
.sp
.RB [ i | o ] csum
.RB [ no ] "" [ i | o ] csum
- generate/require checksums for tunneled packets.
The
.B ocsum

View File

@ -38,7 +38,13 @@ ip-route \- routing table management
.B tos
.IR TOS " ] [ "
.B vrf
.IR NAME " ] "
.IR NAME " ] [ "
.B ipproto
.IR PROTOCOL " ] [ "
.B sport
.IR NUMBER " ] [ "
.B dport
.IR NUMBER " ] "
.ti -8
.BR "ip route" " { " add " | " del " | " change " | " append " | "\
@ -1044,6 +1050,18 @@ the firewall mark
.BI vrf " NAME"
force the vrf device on which this packet will be routed.
.TP
.BI ipproto " PROTOCOL"
ip protocol as seen by the route lookup
.TP
.BI sport " NUMBER"
source port as seen by the route lookup
.TP
.BI dport " NUMBER"
destination port as seen by the route lookup
.TP
.B connected
if no source address

View File

@ -7,12 +7,15 @@ rdma-resource \- rdma resource configuration
.in +8
.ti -8
.B rdma
.RI "[ " OPTIONS " ]"
.B resource
.RI " { " COMMAND " | "
.RI "[ " OPTIONS " ] " RESOURCE " { " COMMAND " | "
.BR help " }"
.sp
.ti -8
.IR RESOURCE " := { "
.BR cm_id " | " cq " | " mr " | " pd " | " qp " }"
.sp
.ti -8
.IR OPTIONS " := { "
\fB\-j\fR[\fIson\fR] |
@ -70,11 +73,31 @@ rdma res show qp link mlx5_4/- -d
Detailed view.
.RE
.PP
rdma res show qp link mlx5_4/- -dd
.RS 4
Detailed view including driver-specific details.
.RE
.PP
rdma res show qp link mlx5_4/1 lqpn 0-6
.RS 4
Limit to specific Local QPNs.
.RE
.PP
rdma resource show cm_id dst-port 7174
.RS 4
Show CM_IDs with destination ip port of 7174.
.RE
.PP
rdma resource show cm_id src-addr 172.16.0.100
.RS 4
Show CM_IDs bound to local ip address 172.16.0.100
.RE
.PP
rdma resource show cq pid 30489
.RS 4
Show CQs belonging to pid 30489
.RE
.PP
.SH SEE ALSO
.BR rdma (8),

View File

@ -49,7 +49,7 @@ If there were any errors during execution of the commands, the application retur
.TP
.BR "\-d" , " --details"
Output detailed information.
Output detailed information. Adding a second \-d includes driver-specific details.
.TP
.BR "\-p" , " --pretty"

View File

@ -22,6 +22,8 @@ flower \- flow based traffic control filter
.IR MATCH " := { "
.B indev
.IR ifname " | "
.BR verbose
.RI " | "
.BR skip_sw " | " skip_hw
.RI " | { "
.BR dst_mac " | " src_mac " } "
@ -100,6 +102,11 @@ is the name of an interface which must exist at the time of
.B tc
invocation.
.TP
.BI verbose
Enable verbose logging, including offloading errors when not using
.B skip_sw
flag.
.TP
.BI skip_sw
Do not process filter by software. If hardware has no offload support for this
filter, or TC offload is not enabled for the interface, operation will fail.

View File

@ -249,10 +249,22 @@ enum rdma_nldev_command {
RDMA_NLDEV_NUM_OPS
};
enum {
RDMA_NLDEV_ATTR_ENTRY_STRLEN = 16,
};
enum rdma_nldev_print_type {
RDMA_NLDEV_PRINT_TYPE_UNSPEC,
RDMA_NLDEV_PRINT_TYPE_HEX,
};
enum rdma_nldev_attr {
/* don't change the order or add anything between, this is ABI! */
RDMA_NLDEV_ATTR_UNSPEC,
/* Pad attribute for 64b alignment */
RDMA_NLDEV_ATTR_PAD = RDMA_NLDEV_ATTR_UNSPEC,
/* Identifier for ib_device */
RDMA_NLDEV_ATTR_DEV_INDEX, /* u32 */
@ -387,7 +399,6 @@ enum rdma_nldev_attr {
RDMA_NLDEV_ATTR_RES_PD_ENTRY, /* nested table */
RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY, /* u32 */
RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY, /* u32 */
/*
* Provides logical name and index of netdevice which is
* connected to physical port. This information is relevant
@ -400,7 +411,24 @@ enum rdma_nldev_attr {
*/
RDMA_NLDEV_ATTR_NDEV_INDEX, /* u32 */
RDMA_NLDEV_ATTR_NDEV_NAME, /* string */
/*
* driver-specific attributes.
*/
RDMA_NLDEV_ATTR_DRIVER, /* nested table */
RDMA_NLDEV_ATTR_DRIVER_ENTRY, /* nested table */
RDMA_NLDEV_ATTR_DRIVER_STRING, /* string */
/*
* u8 values from enum rdma_nldev_print_type
*/
RDMA_NLDEV_ATTR_DRIVER_PRINT_TYPE, /* u8 */
RDMA_NLDEV_ATTR_DRIVER_S32, /* s32 */
RDMA_NLDEV_ATTR_DRIVER_U32, /* u32 */
RDMA_NLDEV_ATTR_DRIVER_S64, /* s64 */
RDMA_NLDEV_ATTR_DRIVER_U64, /* u64 */
/*
* Always the end
*/
RDMA_NLDEV_ATTR_MAX
};
#endif /* _RDMA_NETLINK_H */

View File

@ -205,6 +205,26 @@ static void link_print_phys_state(struct rd *rd, struct nlattr **tb)
pr_out("physical_state %s ", phys_state_to_str(phys_state));
}
static void link_print_netdev(struct rd *rd, struct nlattr **tb)
{
const char *netdev_name;
uint32_t idx;
if (!tb[RDMA_NLDEV_ATTR_NDEV_NAME] || !tb[RDMA_NLDEV_ATTR_NDEV_INDEX])
return;
netdev_name = mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_NDEV_NAME]);
idx = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_NDEV_INDEX]);
if (rd->json_output) {
jsonw_string_field(rd->jw, "netdev", netdev_name);
jsonw_uint_field(rd->jw, "netdev_index", idx);
} else {
pr_out("netdev %s ", netdev_name);
if (rd->show_details)
pr_out("netdev_index %u ", idx);
}
}
static int link_parse_cb(const struct nlmsghdr *nlh, void *data)
{
struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
@ -241,6 +261,7 @@ static int link_parse_cb(const struct nlmsghdr *nlh, void *data)
link_print_lmc(rd, tb);
link_print_state(rd, tb);
link_print_phys_state(rd, tb);
link_print_netdev(rd, tb);
if (rd->show_details)
link_print_caps(rd, tb);

View File

@ -129,13 +129,14 @@ int main(int argc, char **argv)
{ "batch", required_argument, NULL, 'b' },
{ NULL, 0, NULL, 0 }
};
bool show_driver_details = false;
const char *batch_file = NULL;
bool pretty_output = false;
bool show_details = false;
bool json_output = false;
bool force = false;
char *filename;
struct rd rd = {};
char *filename;
int opt;
int err;
@ -152,7 +153,10 @@ int main(int argc, char **argv)
pretty_output = true;
break;
case 'd':
show_details = true;
if (show_details)
show_driver_details = true;
else
show_details = true;
break;
case 'j':
json_output = true;
@ -180,6 +184,7 @@ int main(int argc, char **argv)
argv += optind;
rd.show_details = show_details;
rd.show_driver_details = show_driver_details;
rd.json_output = json_output;
rd.pretty_output = pretty_output;

View File

@ -55,6 +55,7 @@ struct rd {
char **argv;
char *filename;
bool show_details;
bool show_driver_details;
struct list_head dev_map_list;
uint32_t dev_idx;
uint32_t port_idx;
@ -115,4 +116,14 @@ int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, uint32_t seq);
void rd_prepare_msg(struct rd *rd, uint32_t cmd, uint32_t *seq, uint16_t flags);
int rd_dev_init_cb(const struct nlmsghdr *nlh, void *data);
int rd_attr_cb(const struct nlattr *attr, void *data);
int rd_attr_check(const struct nlattr *attr, int *typep);
/*
* Print helpers
*/
void print_driver_table(struct rd *rd, struct nlattr *tb);
void newline(struct rd *rd);
void newline_indent(struct rd *rd);
#define MAX_LINE_LENGTH 80
#endif /* _RDMA_TOOL_H_ */

View File

@ -439,10 +439,8 @@ static int res_qp_parse_cb(const struct nlmsghdr *nlh, void *data)
if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
free(comm);
if (rd->json_output)
jsonw_end_array(rd->jw);
else
pr_out("\n");
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
}
return MNL_CB_OK;
}
@ -678,10 +676,8 @@ static int res_cm_id_parse_cb(const struct nlmsghdr *nlh, void *data)
if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
free(comm);
if (rd->json_output)
jsonw_end_array(rd->jw);
else
pr_out("\n");
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
}
return MNL_CB_OK;
}
@ -804,10 +800,8 @@ static int res_cq_parse_cb(const struct nlmsghdr *nlh, void *data)
if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
free(comm);
if (rd->json_output)
jsonw_end_array(rd->jw);
else
pr_out("\n");
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
}
return MNL_CB_OK;
}
@ -919,10 +913,8 @@ static int res_mr_parse_cb(const struct nlmsghdr *nlh, void *data)
if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
free(comm);
if (rd->json_output)
jsonw_end_array(rd->jw);
else
pr_out("\n");
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
}
return MNL_CB_OK;
}
@ -1004,10 +996,8 @@ static int res_pd_parse_cb(const struct nlmsghdr *nlh, void *data)
if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
free(comm);
if (rd->json_output)
jsonw_end_array(rd->jw);
else
pr_out("\n");
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
}
return MNL_CB_OK;
}

View File

@ -11,6 +11,7 @@
#include "rdma.h"
#include <ctype.h>
#include <inttypes.h>
int rd_argc(struct rd *rd)
{
@ -391,8 +392,34 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
[RDMA_NLDEV_ATTR_RES_LKEY] = MNL_TYPE_U32,
[RDMA_NLDEV_ATTR_RES_IOVA] = MNL_TYPE_U64,
[RDMA_NLDEV_ATTR_RES_MRLEN] = MNL_TYPE_U64,
[RDMA_NLDEV_ATTR_NDEV_INDEX] = MNL_TYPE_U32,
[RDMA_NLDEV_ATTR_NDEV_NAME] = MNL_TYPE_NUL_STRING,
[RDMA_NLDEV_ATTR_DRIVER] = MNL_TYPE_NESTED,
[RDMA_NLDEV_ATTR_DRIVER_ENTRY] = MNL_TYPE_NESTED,
[RDMA_NLDEV_ATTR_DRIVER_STRING] = MNL_TYPE_NUL_STRING,
[RDMA_NLDEV_ATTR_DRIVER_PRINT_TYPE] = MNL_TYPE_U8,
[RDMA_NLDEV_ATTR_DRIVER_S32] = MNL_TYPE_U32,
[RDMA_NLDEV_ATTR_DRIVER_U32] = MNL_TYPE_U32,
[RDMA_NLDEV_ATTR_DRIVER_S64] = MNL_TYPE_U64,
[RDMA_NLDEV_ATTR_DRIVER_U64] = MNL_TYPE_U64,
};
int rd_attr_check(const struct nlattr *attr, int *typep)
{
int type;
if (mnl_attr_type_valid(attr, RDMA_NLDEV_ATTR_MAX) < 0)
return MNL_CB_ERROR;
type = mnl_attr_get_type(attr);
if (mnl_attr_validate(attr, nldev_policy[type]) < 0)
return MNL_CB_ERROR;
*typep = nldev_policy[type];
return MNL_CB_OK;
}
int rd_attr_cb(const struct nlattr *attr, void *data)
{
const struct nlattr **tb = data;
@ -658,3 +685,174 @@ struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index)
free(dev_name);
return dev_map;
}
#define nla_type(attr) ((attr)->nla_type & NLA_TYPE_MASK)
void newline(struct rd *rd)
{
if (rd->json_output)
jsonw_end_array(rd->jw);
else
pr_out("\n");
}
void newline_indent(struct rd *rd)
{
newline(rd);
if (!rd->json_output)
pr_out(" ");
}
static int print_driver_string(struct rd *rd, const char *key_str,
const char *val_str)
{
if (rd->json_output) {
jsonw_string_field(rd->jw, key_str, val_str);
return 0;
} else {
return pr_out("%s %s ", key_str, val_str);
}
}
static int print_driver_s32(struct rd *rd, const char *key_str, int32_t val,
enum rdma_nldev_print_type print_type)
{
if (rd->json_output) {
jsonw_int_field(rd->jw, key_str, val);
return 0;
}
switch (print_type) {
case RDMA_NLDEV_PRINT_TYPE_UNSPEC:
return pr_out("%s %d ", key_str, val);
case RDMA_NLDEV_PRINT_TYPE_HEX:
return pr_out("%s 0x%x ", key_str, val);
default:
return -EINVAL;
}
}
static int print_driver_u32(struct rd *rd, const char *key_str, uint32_t val,
enum rdma_nldev_print_type print_type)
{
if (rd->json_output) {
jsonw_int_field(rd->jw, key_str, val);
return 0;
}
switch (print_type) {
case RDMA_NLDEV_PRINT_TYPE_UNSPEC:
return pr_out("%s %u ", key_str, val);
case RDMA_NLDEV_PRINT_TYPE_HEX:
return pr_out("%s 0x%x ", key_str, val);
default:
return -EINVAL;
}
}
static int print_driver_s64(struct rd *rd, const char *key_str, int64_t val,
enum rdma_nldev_print_type print_type)
{
if (rd->json_output) {
jsonw_int_field(rd->jw, key_str, val);
return 0;
}
switch (print_type) {
case RDMA_NLDEV_PRINT_TYPE_UNSPEC:
return pr_out("%s %" PRId64 " ", key_str, val);
case RDMA_NLDEV_PRINT_TYPE_HEX:
return pr_out("%s 0x%" PRIx64 " ", key_str, val);
default:
return -EINVAL;
}
}
static int print_driver_u64(struct rd *rd, const char *key_str, uint64_t val,
enum rdma_nldev_print_type print_type)
{
if (rd->json_output) {
jsonw_int_field(rd->jw, key_str, val);
return 0;
}
switch (print_type) {
case RDMA_NLDEV_PRINT_TYPE_UNSPEC:
return pr_out("%s %" PRIu64 " ", key_str, val);
case RDMA_NLDEV_PRINT_TYPE_HEX:
return pr_out("%s 0x%" PRIx64 " ", key_str, val);
default:
return -EINVAL;
}
}
static int print_driver_entry(struct rd *rd, struct nlattr *key_attr,
struct nlattr *val_attr,
enum rdma_nldev_print_type print_type)
{
const char *key_str = mnl_attr_get_str(key_attr);
int attr_type = nla_type(val_attr);
switch (attr_type) {
case RDMA_NLDEV_ATTR_DRIVER_STRING:
return print_driver_string(rd, key_str,
mnl_attr_get_str(val_attr));
case RDMA_NLDEV_ATTR_DRIVER_S32:
return print_driver_s32(rd, key_str,
mnl_attr_get_u32(val_attr), print_type);
case RDMA_NLDEV_ATTR_DRIVER_U32:
return print_driver_u32(rd, key_str,
mnl_attr_get_u32(val_attr), print_type);
case RDMA_NLDEV_ATTR_DRIVER_S64:
return print_driver_s64(rd, key_str,
mnl_attr_get_u64(val_attr), print_type);
case RDMA_NLDEV_ATTR_DRIVER_U64:
return print_driver_u64(rd, key_str,
mnl_attr_get_u64(val_attr), print_type);
}
return -EINVAL;
}
void print_driver_table(struct rd *rd, struct nlattr *tb)
{
int print_type = RDMA_NLDEV_PRINT_TYPE_UNSPEC;
struct nlattr *tb_entry, *key = NULL, *val;
int type, cc = 0;
int ret;
if (!rd->show_driver_details || !tb)
return;
if (rd->pretty_output)
newline_indent(rd);
/*
* Driver attrs are tuples of {key, [print-type], value}.
* The key must be a string. If print-type is present, it
* defines an alternate printf format type vs the native format
* for the attribute. And the value can be any available
* driver type.
*/
mnl_attr_for_each_nested(tb_entry, tb) {
if (cc > MAX_LINE_LENGTH) {
if (rd->pretty_output)
newline_indent(rd);
cc = 0;
}
if (rd_attr_check(tb_entry, &type) != MNL_CB_OK)
return;
if (!key) {
if (type != MNL_TYPE_NUL_STRING)
return;
key = tb_entry;
} else if (type == MNL_TYPE_U8) {
print_type = mnl_attr_get_u8(tb_entry);
} else {
val = tb_entry;
ret = print_driver_entry(rd, key, val, print_type);
if (ret < 0)
return;
cc += ret;
print_type = RDMA_NLDEV_PRINT_TYPE_UNSPEC;
key = NULL;
}
}
return;
}

View File

@ -41,7 +41,7 @@ enum flower_icmp_field {
static void explain(void)
{
fprintf(stderr,
"Usage: ... flower [ MATCH-LIST ]\n"
"Usage: ... flower [ MATCH-LIST ] [ verbose ]\n"
" [ skip_sw | skip_hw ]\n"
" [ action ACTION-SPEC ] [ classid CLASSID ]\n"
"\n"
@ -648,6 +648,8 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
fprintf(stderr, "Illegal \"ip_flags\"\n");
return -1;
}
} else if (matches(*argv, "verbose") == 0) {
flags |= TCA_CLS_FLAGS_VERBOSE;
} else if (matches(*argv, "skip_hw") == 0) {
flags |= TCA_CLS_FLAGS_SKIP_HW;
} else if (matches(*argv, "skip_sw") == 0) {

View File

@ -114,16 +114,20 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_CONNMARK_MAX, arg);
if (tb[TCA_CONNMARK_PARMS] == NULL) {
fprintf(f, "[NULL connmark parameters]");
print_string(PRINT_FP, NULL, "%s", "[NULL connmark parameters]");
return -1;
}
ci = RTA_DATA(tb[TCA_CONNMARK_PARMS]);
fprintf(f, " connmark zone %d", ci->zone);
print_action_control(f, " ", ci->action, "\n");
fprintf(f, "\t index %u ref %d bind %d", ci->index,
ci->refcnt, ci->bindcnt);
print_string(PRINT_ANY, "kind", "%s ", "connmark");
print_uint(PRINT_ANY, "zone", "zone %u", ci->zone);
print_action_control(f, " ", ci->action, "");
print_string(PRINT_FP, NULL, "%s", _SL_);
print_uint(PRINT_ANY, "index", "\t index %u", ci->index);
print_int(PRINT_ANY, "ref", " ref %d", ci->refcnt);
print_int(PRINT_ANY, "bind", " bind %d", ci->bindcnt);
if (show_stats) {
if (tb[TCA_CONNMARK_TM]) {
@ -132,7 +136,7 @@ static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
print_tm(f, tm);
}
}
fprintf(f, "\n");
print_string(PRINT_FP, NULL, "%s", _SL_);
return 0;
}

View File

@ -162,6 +162,7 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
char *uflag_5 = "";
char *uflag_6 = "";
char *uflag_7 = "";
SPRINT_BUF(buf);
int uflag_count = 0;
@ -198,12 +199,15 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
uflag_1 = "?empty";
}
fprintf(f, "csum (%s%s%s%s%s%s%s) ",
uflag_1, uflag_2, uflag_3,
uflag_4, uflag_5, uflag_6, uflag_7);
snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s",
uflag_1, uflag_2, uflag_3,
uflag_4, uflag_5, uflag_6, uflag_7);
print_string(PRINT_ANY, "csum", "csum (%s) ", buf);
print_action_control(f, "action ", sel->action, "\n");
fprintf(f, "\tindex %u ref %d bind %d", sel->index, sel->refcnt,
sel->bindcnt);
print_uint(PRINT_ANY, "index", "\tindex %u", sel->index);
print_int(PRINT_ANY, "ref", " ref %d", sel->refcnt);
print_int(PRINT_ANY, "bind", " bind %d", sel->bindcnt);
if (show_stats) {
if (tb[TCA_CSUM_TM]) {
@ -212,7 +216,7 @@ print_csum(struct action_util *au, FILE *f, struct rtattr *arg)
print_tm(f, tm);
}
}
fprintf(f, "\n");
print_string(PRINT_FP, NULL, "%s", "\n");
return 0;
}

View File

@ -234,22 +234,24 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_IFE_MAX, arg);
if (tb[TCA_IFE_PARMS] == NULL) {
fprintf(f, "[NULL ife parameters]");
print_string(PRINT_FP, NULL, "%s", "[NULL ife parameters]");
return -1;
}
p = RTA_DATA(tb[TCA_IFE_PARMS]);
fprintf(f, "ife %s ", p->flags & IFE_ENCODE ? "encode" : "decode");
print_string(PRINT_ANY, "kind", "%s ", "ife");
print_string(PRINT_ANY, "mode", "%s ",
p->flags & IFE_ENCODE ? "encode" : "decode");
print_action_control(f, "action ", p->action, " ");
if (tb[TCA_IFE_TYPE]) {
ife_type = rta_getattr_u16(tb[TCA_IFE_TYPE]);
has_optional = 1;
fprintf(f, "type 0x%X ", ife_type);
print_0xhex(PRINT_ANY, "type", "type 0x%X ", ife_type);
}
if (has_optional)
fprintf(f, "\n\t ");
print_string(PRINT_FP, NULL, "%s\t", _SL_);
if (tb[TCA_IFE_METALST]) {
struct rtattr *metalist[IFE_META_MAX + 1];
@ -262,9 +264,11 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
len = RTA_PAYLOAD(metalist[IFE_META_SKBMARK]);
if (len) {
mmark = rta_getattr_u32(metalist[IFE_META_SKBMARK]);
fprintf(f, "use mark %u ", mmark);
print_uint(PRINT_ANY, "mark", "use mark %u ",
mmark);
} else
fprintf(f, "allow mark ");
print_string(PRINT_ANY, "mark", "%s mark ",
"allow");
}
if (metalist[IFE_META_TCINDEX]) {
@ -272,41 +276,47 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
if (len) {
mtcindex =
rta_getattr_u16(metalist[IFE_META_TCINDEX]);
fprintf(f, "use tcindex %d ", mtcindex);
print_uint(PRINT_ANY, "tcindex",
"use tcindex %u ", mtcindex);
} else
fprintf(f, "allow tcindex ");
print_string(PRINT_ANY, "tcindex",
"%s tcindex ", "allow");
}
if (metalist[IFE_META_PRIO]) {
len = RTA_PAYLOAD(metalist[IFE_META_PRIO]);
if (len) {
mprio = rta_getattr_u32(metalist[IFE_META_PRIO]);
fprintf(f, "use prio %u ", mprio);
print_uint(PRINT_ANY, "prio", "use prio %u ",
mprio);
} else
fprintf(f, "allow prio ");
print_string(PRINT_ANY, "prio", "%s prio ",
"allow");
}
}
if (tb[TCA_IFE_DMAC]) {
has_optional = 1;
fprintf(f, "dst %s ",
ll_addr_n2a(RTA_DATA(tb[TCA_IFE_DMAC]),
RTA_PAYLOAD(tb[TCA_IFE_DMAC]), 0, b2,
sizeof(b2)));
print_string(PRINT_ANY, "dst", "dst %s ",
ll_addr_n2a(RTA_DATA(tb[TCA_IFE_DMAC]),
RTA_PAYLOAD(tb[TCA_IFE_DMAC]), 0, b2,
sizeof(b2)));
}
if (tb[TCA_IFE_SMAC]) {
has_optional = 1;
fprintf(f, "src %s ",
ll_addr_n2a(RTA_DATA(tb[TCA_IFE_SMAC]),
RTA_PAYLOAD(tb[TCA_IFE_SMAC]), 0, b2,
sizeof(b2)));
print_string(PRINT_ANY, "src", "src %s ",
ll_addr_n2a(RTA_DATA(tb[TCA_IFE_SMAC]),
RTA_PAYLOAD(tb[TCA_IFE_SMAC]), 0, b2,
sizeof(b2)));
}
fprintf(f, "\n\t index %u ref %d bind %d", p->index, p->refcnt,
p->bindcnt);
print_string(PRINT_FP, NULL, "%s", _SL_);
print_uint(PRINT_ANY, "index", "\t index %u", p->index);
print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
if (show_stats) {
if (tb[TCA_IFE_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_IFE_TM]);
@ -315,7 +325,7 @@ static int print_ife(struct action_util *au, FILE *f, struct rtattr *arg)
}
}
fprintf(f, "\n");
print_string(PRINT_FP, NULL, "%s", _SL_);
return 0;
}

View File

@ -168,9 +168,8 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
struct rtattr *tb[TCA_SKBEDIT_MAX + 1];
SPRINT_BUF(b1);
__u32 *priority;
__u32 *mark;
__u16 *queue_mapping, *ptype;
__u32 priority;
__u16 ptype;
struct tc_skbedit *p = NULL;
if (arg == NULL)
@ -179,43 +178,49 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_SKBEDIT_MAX, arg);
if (tb[TCA_SKBEDIT_PARMS] == NULL) {
fprintf(f, "[NULL skbedit parameters]");
print_string(PRINT_FP, NULL, "%s", "[NULL skbedit parameters]");
return -1;
}
p = RTA_DATA(tb[TCA_SKBEDIT_PARMS]);
fprintf(f, " skbedit");
print_string(PRINT_ANY, "kind", "%s ", "skbedit");
if (tb[TCA_SKBEDIT_QUEUE_MAPPING] != NULL) {
queue_mapping = RTA_DATA(tb[TCA_SKBEDIT_QUEUE_MAPPING]);
fprintf(f, " queue_mapping %u", *queue_mapping);
print_uint(PRINT_ANY, "queue_mapping", "queue_mapping %u",
rta_getattr_u16(tb[TCA_SKBEDIT_QUEUE_MAPPING]));
}
if (tb[TCA_SKBEDIT_PRIORITY] != NULL) {
priority = RTA_DATA(tb[TCA_SKBEDIT_PRIORITY]);
fprintf(f, " priority %s", sprint_tc_classid(*priority, b1));
priority = rta_getattr_u32(tb[TCA_SKBEDIT_PRIORITY]);
print_string(PRINT_ANY, "priority", " priority %s",
sprint_tc_classid(priority, b1));
}
if (tb[TCA_SKBEDIT_MARK] != NULL) {
mark = RTA_DATA(tb[TCA_SKBEDIT_MARK]);
fprintf(f, " mark %d", *mark);
print_uint(PRINT_ANY, "mark", " mark %u",
rta_getattr_u32(tb[TCA_SKBEDIT_MARK]));
}
if (tb[TCA_SKBEDIT_PTYPE] != NULL) {
ptype = RTA_DATA(tb[TCA_SKBEDIT_PTYPE]);
if (*ptype == PACKET_HOST)
fprintf(f, " ptype host");
else if (*ptype == PACKET_BROADCAST)
fprintf(f, " ptype broadcast");
else if (*ptype == PACKET_MULTICAST)
fprintf(f, " ptype multicast");
else if (*ptype == PACKET_OTHERHOST)
fprintf(f, " ptype otherhost");
ptype = rta_getattr_u16(tb[TCA_SKBEDIT_PTYPE]);
if (ptype == PACKET_HOST)
print_string(PRINT_ANY, "ptype", " ptype %s", "host");
else if (ptype == PACKET_BROADCAST)
print_string(PRINT_ANY, "ptype", " ptype %s",
"broadcast");
else if (ptype == PACKET_MULTICAST)
print_string(PRINT_ANY, "ptype", " ptype %s",
"multicast");
else if (ptype == PACKET_OTHERHOST)
print_string(PRINT_ANY, "ptype", " ptype %s",
"otherhost");
else
fprintf(f, " ptype %d", *ptype);
print_uint(PRINT_ANY, "ptype", " ptype %u", ptype);
}
print_action_control(f, " ", p->action, "");
fprintf(f, "\n\t index %u ref %d bind %d",
p->index, p->refcnt, p->bindcnt);
print_string(PRINT_FP, NULL, "%s", _SL_);
print_uint(PRINT_ANY, "index", "\t index %u", p->index);
print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
if (show_stats) {
if (tb[TCA_SKBEDIT_TM]) {
@ -225,7 +230,7 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg)
}
}
fprintf(f, "\n ");
print_string(PRINT_FP, NULL, "%s", _SL_);
return 0;
}

View File

@ -221,7 +221,13 @@ static void tunnel_key_print_ip_addr(FILE *f, const char *name,
else
return;
fprintf(f, "\n\t%s %s", name, rt_addr_n2a_rta(family, attr));
print_string(PRINT_FP, NULL, "%s", _SL_);
if (matches(name, "src_ip") == 0)
print_string(PRINT_ANY, "src_ip", "\tsrc_ip %s",
rt_addr_n2a_rta(family, attr));
else if (matches(name, "dst_ip") == 0)
print_string(PRINT_ANY, "dst_ip", "\tdst_ip %s",
rt_addr_n2a_rta(family, attr));
}
static void tunnel_key_print_key_id(FILE *f, const char *name,
@ -229,7 +235,8 @@ static void tunnel_key_print_key_id(FILE *f, const char *name,
{
if (!attr)
return;
fprintf(f, "\n\t%s %d", name, rta_getattr_be32(attr));
print_string(PRINT_FP, NULL, "%s", _SL_);
print_uint(PRINT_ANY, "key_id", "\tkey_id %u", rta_getattr_be32(attr));
}
static void tunnel_key_print_dst_port(FILE *f, char *name,
@ -237,7 +244,9 @@ static void tunnel_key_print_dst_port(FILE *f, char *name,
{
if (!attr)
return;
fprintf(f, "\n\t%s %d", name, rta_getattr_be16(attr));
print_string(PRINT_FP, NULL, "%s", _SL_);
print_uint(PRINT_ANY, "dst_port", "\tdst_port %u",
rta_getattr_be16(attr));
}
static void tunnel_key_print_flag(FILE *f, const char *name_on,
@ -246,7 +255,9 @@ static void tunnel_key_print_flag(FILE *f, const char *name_on,
{
if (!attr)
return;
fprintf(f, "\n\t%s", rta_getattr_u8(attr) ? name_on : name_off);
print_string(PRINT_FP, NULL, "%s", _SL_);
print_string(PRINT_ANY, "flag", "\t%s",
rta_getattr_u8(attr) ? name_on : name_off);
}
static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
@ -260,19 +271,20 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
parse_rtattr_nested(tb, TCA_TUNNEL_KEY_MAX, arg);
if (!tb[TCA_TUNNEL_KEY_PARMS]) {
fprintf(f, "[NULL tunnel_key parameters]");
print_string(PRINT_FP, NULL, "%s",
"[NULL tunnel_key parameters]");
return -1;
}
parm = RTA_DATA(tb[TCA_TUNNEL_KEY_PARMS]);
fprintf(f, "tunnel_key");
print_string(PRINT_ANY, "kind", "%s ", "tunnel_key");
switch (parm->t_action) {
case TCA_TUNNEL_KEY_ACT_RELEASE:
fprintf(f, " unset");
print_string(PRINT_ANY, "mode", " %s", "unset");
break;
case TCA_TUNNEL_KEY_ACT_SET:
fprintf(f, " set");
print_string(PRINT_ANY, "mode", " %s", "set");
tunnel_key_print_ip_addr(f, "src_ip",
tb[TCA_TUNNEL_KEY_ENC_IPV4_SRC]);
tunnel_key_print_ip_addr(f, "dst_ip",
@ -291,8 +303,10 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
}
print_action_control(f, " ", parm->action, "");
fprintf(f, "\n\tindex %d ref %d bind %d", parm->index, parm->refcnt,
parm->bindcnt);
print_string(PRINT_FP, NULL, "%s", _SL_);
print_uint(PRINT_ANY, "index", "\t index %u", parm->index);
print_int(PRINT_ANY, "ref", " ref %d", parm->refcnt);
print_int(PRINT_ANY, "bind", " bind %d", parm->bindcnt);
if (show_stats) {
if (tb[TCA_TUNNEL_KEY_TM]) {
@ -302,7 +316,7 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
}
}
fprintf(f, "\n ");
print_string(PRINT_FP, NULL, "%s", _SL_);
return 0;
}

View File

@ -42,7 +42,8 @@ static void _print_bearer_opts(void)
"OPTIONS\n"
" priority - Bearer link priority\n"
" tolerance - Bearer link tolerance\n"
" window - Bearer link window\n");
" window - Bearer link window\n"
" mtu - Bearer link mtu\n");
}
void print_bearer_media(void)
@ -194,6 +195,21 @@ static int nl_add_udp_enable_opts(struct nlmsghdr *nlh, struct opt *opts,
return 0;
}
static char *cmd_get_media_type(const struct cmd *cmd, struct cmdl *cmdl,
struct opt *opts)
{
struct opt *opt = get_opt(opts, "media");
if (!opt) {
if (help_flag)
(cmd->help)(cmdl);
else
fprintf(stderr, "error, missing bearer media\n");
return NULL;
}
return opt->val;
}
static int nl_add_bearer_name(struct nlmsghdr *nlh, const struct cmd *cmd,
struct cmdl *cmdl, struct opt *opts,
const struct tipc_sup_media *sup_media)
@ -217,15 +233,8 @@ int cmd_get_unique_bearer_name(const struct cmd *cmd, struct cmdl *cmdl,
struct opt *opt;
const struct tipc_sup_media *entry;
if (!(opt = get_opt(opts, "media"))) {
if (help_flag)
(cmd->help)(cmdl);
else
fprintf(stderr, "error, missing bearer media\n");
if (!(media = cmd_get_media_type(cmd, cmdl, opts)))
return -EINVAL;
}
media = opt->val;
for (entry = sup_media; entry->media; entry++) {
if (strcmp(entry->media, media))
@ -559,6 +568,8 @@ static int cmd_bearer_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
prop = TIPC_NLA_PROP_TOL;
else if ((strcmp(cmd->cmd, "window") == 0))
prop = TIPC_NLA_PROP_WIN;
else if ((strcmp(cmd->cmd, "mtu") == 0))
prop = TIPC_NLA_PROP_MTU;
else
return -EINVAL;
@ -571,6 +582,17 @@ static int cmd_bearer_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
if (parse_opts(opts, cmdl) < 0)
return -EINVAL;
if (prop == TIPC_NLA_PROP_MTU) {
char *media = cmd_get_media_type(cmd, cmdl, opts);
if (!media)
return -EINVAL;
else if (strcmp(media, "udp")) {
fprintf(stderr, "error, not supported for media\n");
return -EINVAL;
}
}
if (!(nlh = msg_init(buf, TIPC_NL_BEARER_SET))) {
fprintf(stderr, "error, message initialisation failed\n");
return -1;
@ -597,6 +619,7 @@ static int cmd_bearer_set(struct nlmsghdr *nlh, const struct cmd *cmd,
{ "priority", cmd_bearer_set_prop, cmd_bearer_set_help },
{ "tolerance", cmd_bearer_set_prop, cmd_bearer_set_help },
{ "window", cmd_bearer_set_prop, cmd_bearer_set_help },
{ "mtu", cmd_bearer_set_prop, cmd_bearer_set_help },
{ NULL }
};
@ -877,12 +900,25 @@ static int cmd_bearer_get_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
prop = TIPC_NLA_PROP_TOL;
else if ((strcmp(cmd->cmd, "window") == 0))
prop = TIPC_NLA_PROP_WIN;
else if ((strcmp(cmd->cmd, "mtu") == 0))
prop = TIPC_NLA_PROP_MTU;
else
return -EINVAL;
if (parse_opts(opts, cmdl) < 0)
return -EINVAL;
if (prop == TIPC_NLA_PROP_MTU) {
char *media = cmd_get_media_type(cmd, cmdl, opts);
if (!media)
return -EINVAL;
else if (strcmp(media, "udp")) {
fprintf(stderr, "error, not supported for media\n");
return -EINVAL;
}
}
if (!(nlh = msg_init(buf, TIPC_NL_BEARER_GET))) {
fprintf(stderr, "error, message initialisation failed\n");
return -1;
@ -904,6 +940,7 @@ static int cmd_bearer_get(struct nlmsghdr *nlh, const struct cmd *cmd,
{ "priority", cmd_bearer_get_prop, cmd_bearer_get_help },
{ "tolerance", cmd_bearer_get_prop, cmd_bearer_get_help },
{ "window", cmd_bearer_get_prop, cmd_bearer_get_help },
{ "mtu", cmd_bearer_get_prop, cmd_bearer_get_help },
{ "media", cmd_bearer_get_media, cmd_bearer_get_help },
{ NULL }
};

View File

@ -103,6 +103,8 @@ static int cmd_media_get_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
prop = TIPC_NLA_PROP_TOL;
else if ((strcmp(cmd->cmd, "window") == 0))
prop = TIPC_NLA_PROP_WIN;
else if ((strcmp(cmd->cmd, "mtu") == 0))
prop = TIPC_NLA_PROP_MTU;
else
return -EINVAL;
@ -123,6 +125,12 @@ static int cmd_media_get_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
fprintf(stderr, "error, missing media\n");
return -EINVAL;
}
if ((prop == TIPC_NLA_PROP_MTU) &&
(strcmp(opt->val, "udp"))) {
fprintf(stderr, "error, not supported for media\n");
return -EINVAL;
}
nest = mnl_attr_nest_start(nlh, TIPC_NLA_MEDIA);
mnl_attr_put_strz(nlh, TIPC_NLA_MEDIA_NAME, opt->val);
mnl_attr_nest_end(nlh, nest);
@ -136,7 +144,8 @@ static void cmd_media_get_help(struct cmdl *cmdl)
"PROPERTIES\n"
" tolerance - Get media tolerance\n"
" priority - Get media priority\n"
" window - Get media window\n",
" window - Get media window\n"
" mtu - Get media mtu\n",
cmdl->argv[0]);
}
@ -147,6 +156,7 @@ static int cmd_media_get(struct nlmsghdr *nlh, const struct cmd *cmd,
{ "priority", cmd_media_get_prop, cmd_media_get_help },
{ "tolerance", cmd_media_get_prop, cmd_media_get_help },
{ "window", cmd_media_get_prop, cmd_media_get_help },
{ "mtu", cmd_media_get_prop, cmd_media_get_help },
{ NULL }
};
@ -159,7 +169,8 @@ static void cmd_media_set_help(struct cmdl *cmdl)
"PROPERTIES\n"
" tolerance TOLERANCE - Set media tolerance\n"
" priority PRIORITY - Set media priority\n"
" window WINDOW - Set media window\n",
" window WINDOW - Set media window\n"
" mtu MTU - Set media mtu\n",
cmdl->argv[0]);
}
@ -183,6 +194,8 @@ static int cmd_media_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
prop = TIPC_NLA_PROP_TOL;
else if ((strcmp(cmd->cmd, "window") == 0))
prop = TIPC_NLA_PROP_WIN;
else if ((strcmp(cmd->cmd, "mtu") == 0))
prop = TIPC_NLA_PROP_MTU;
else
return -EINVAL;
@ -210,6 +223,12 @@ static int cmd_media_set_prop(struct nlmsghdr *nlh, const struct cmd *cmd,
fprintf(stderr, "error, missing media\n");
return -EINVAL;
}
if ((prop == TIPC_NLA_PROP_MTU) &&
(strcmp(opt->val, "udp"))) {
fprintf(stderr, "error, not supported for media\n");
return -EINVAL;
}
mnl_attr_put_strz(nlh, TIPC_NLA_MEDIA_NAME, opt->val);
props = mnl_attr_nest_start(nlh, TIPC_NLA_MEDIA_PROP);
@ -228,6 +247,7 @@ static int cmd_media_set(struct nlmsghdr *nlh, const struct cmd *cmd,
{ "priority", cmd_media_set_prop, cmd_media_set_help },
{ "tolerance", cmd_media_set_prop, cmd_media_set_help },
{ "window", cmd_media_set_prop, cmd_media_set_help },
{ "mtu", cmd_media_set_prop, cmd_media_set_help },
{ NULL }
};

View File

@ -13,6 +13,10 @@
#include <stdint.h>
#include <linux/tipc.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <unistd.h>
#include <errno.h>
#include "misc.h"
#define IN_RANGE(val, low, high) ((val) <= (high) && (val) >= (low))
@ -109,3 +113,19 @@ void nodeid2str(uint8_t *id, char *str)
for (i = 31; str[i] == '0'; i--)
str[i] = 0;
}
void hash2nodestr(uint32_t hash, char *str)
{
struct tipc_sioc_nodeid_req nr = {};
int sd;
sd = socket(AF_TIPC, SOCK_RDM, 0);
if (sd < 0) {
fprintf(stderr, "opening TIPC socket: %s\n", strerror(errno));
return;
}
nr.peer = hash;
if (!ioctl(sd, SIOCGETNODEID, &nr))
nodeid2str((uint8_t *)nr.node_id, str);
close(sd);
}

View File

@ -17,5 +17,6 @@
uint32_t str2addr(char *str);
int str2nodeid(char *str, uint8_t *id);
void nodeid2str(uint8_t *id, char *str);
void hash2nodestr(uint32_t hash, char *str);
#endif

View File

@ -20,6 +20,7 @@
#include "cmdl.h"
#include "msg.h"
#include "nametable.h"
#include "misc.h"
#define PORTID_STR_LEN 45 /* Four u32 and five delimiter chars */
@ -31,6 +32,7 @@ static int nametable_show_cb(const struct nlmsghdr *nlh, void *data)
struct nlattr *attrs[TIPC_NLA_NAME_TABLE_MAX + 1] = {};
struct nlattr *publ[TIPC_NLA_PUBL_MAX + 1] = {};
const char *scope[] = { "", "zone", "cluster", "node" };
char str[33] = {0,};
mnl_attr_parse(nlh, sizeof(*genl), parse_attrs, info);
if (!info[TIPC_NLA_NAME_TABLE])
@ -45,20 +47,20 @@ static int nametable_show_cb(const struct nlmsghdr *nlh, void *data)
return MNL_CB_ERROR;
if (!*iteration)
printf("%-10s %-10s %-10s %-10s %-10s %-10s\n",
"Type", "Lower", "Upper", "Node", "Port",
"Publication Scope");
printf("%-10s %-10s %-10s %-8s %-10s %-33s\n",
"Type", "Lower", "Upper", "Scope", "Port",
"Node");
(*iteration)++;
printf("%-10u %-10u %-10u %-10x %-10u %-12u",
hash2nodestr(mnl_attr_get_u32(publ[TIPC_NLA_PUBL_NODE]), str);
printf("%-10u %-10u %-10u %-8s %-10u %s\n",
mnl_attr_get_u32(publ[TIPC_NLA_PUBL_TYPE]),
mnl_attr_get_u32(publ[TIPC_NLA_PUBL_LOWER]),
mnl_attr_get_u32(publ[TIPC_NLA_PUBL_UPPER]),
mnl_attr_get_u32(publ[TIPC_NLA_PUBL_NODE]),
scope[mnl_attr_get_u32(publ[TIPC_NLA_PUBL_SCOPE])],
mnl_attr_get_u32(publ[TIPC_NLA_PUBL_REF]),
mnl_attr_get_u32(publ[TIPC_NLA_PUBL_KEY]));
printf("%s\n", scope[mnl_attr_get_u32(publ[TIPC_NLA_PUBL_SCOPE])]);
str);
return MNL_CB_OK;
}

View File

@ -26,10 +26,11 @@
static int node_list_cb(const struct nlmsghdr *nlh, void *data)
{
uint32_t addr;
struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
struct nlattr *info[TIPC_NLA_MAX + 1] = {};
struct nlattr *attrs[TIPC_NLA_NODE_MAX + 1] = {};
char str[33] = {};
uint32_t addr;
mnl_attr_parse(nlh, sizeof(*genl), parse_attrs, info);
if (!info[TIPC_NLA_NODE])
@ -40,13 +41,12 @@ static int node_list_cb(const struct nlmsghdr *nlh, void *data)
return MNL_CB_ERROR;
addr = mnl_attr_get_u32(attrs[TIPC_NLA_NODE_ADDR]);
printf("%x: ", addr);
hash2nodestr(addr, str);
printf("%-32s %08x ", str, addr);
if (attrs[TIPC_NLA_NODE_UP])
printf("up\n");
else
printf("down\n");
return MNL_CB_OK;
}
@ -64,7 +64,7 @@ static int cmd_node_list(struct nlmsghdr *nlh, const struct cmd *cmd,
fprintf(stderr, "error, message initialisation failed\n");
return -1;
}
printf("Node Identity Hash State\n");
return msg_dumpit(nlh, node_list_cb, NULL);
}
@ -120,7 +120,7 @@ static int cmd_node_get_addr(struct nlmsghdr *nlh, const struct cmd *cmd,
}
close(sk);
printf("%x\n", addr.addr.id.node);
printf("%08x\n", addr.addr.id.node);
return 0;
}
@ -167,7 +167,6 @@ static int nodeid_get_cb(const struct nlmsghdr *nlh, void *data)
uint8_t id[16] = {0,};
uint64_t *w0 = (uint64_t *) &id[0];
uint64_t *w1 = (uint64_t *) &id[8];
int i;
mnl_attr_parse(nlh, sizeof(*genl), parse_attrs, info);
if (!info[TIPC_NLA_NET])
@ -180,10 +179,8 @@ static int nodeid_get_cb(const struct nlmsghdr *nlh, void *data)
*w0 = mnl_attr_get_u64(attrs[TIPC_NLA_NET_NODEID]);
*w1 = mnl_attr_get_u64(attrs[TIPC_NLA_NET_NODEID_W1]);
nodeid2str(id, str);
printf("Node Identity Hash\n");
printf("%s", str);
for (i = strlen(str); i <= 33; i++)
printf(" ");
printf("Node Identity Hash\n");
printf("%-33s", str);
cmd_node_get_addr(NULL, NULL, NULL, NULL);
return MNL_CB_OK;
}

View File

@ -39,7 +39,11 @@ static int cmd_peer_rm_addr(struct nlmsghdr *nlh, const struct cmd *cmd,
}
str = shift_cmdl(cmdl);
/* First try legacy Z.C.N format, then integer format */
addr = str2addr(str);
if (!addr)
addr = atoi(str);
if (!addr)
return -1;