#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <syslog.h>
#include <inttypes.h>
#include <fcntl.h>
#include <sys/ioctl.h>
fprintf(stderr, "CONFFLAG := [ home | nodad | mngtmpaddr | noprefixroute | autojoin ]\n");
fprintf(stderr, "LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]\n");
fprintf(stderr, "LFT := forever | SECONDS\n");
- fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | macvtap |\n");
+ fprintf(stderr, "TYPE := { vlan | veth | vcan | vxcan | dummy | ifb | macvlan | macvtap |\n");
fprintf(stderr, " bridge | bond | ipoib | ip6tnl | ipip | sit | vxlan | lowpan |\n");
- fprintf(stderr, " gre | gretap | erspan | ip6gre | ip6gretap | vti | nlmon | can |\n");
- fprintf(stderr, " bond_slave | ipvlan | geneve | bridge_slave | vrf | hsr | macsec }\n");
+ fprintf(stderr, " gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan | vti |\n");
+ fprintf(stderr, " nlmon | can | bond_slave | ipvlan | geneve | bridge_slave |\n");
+ fprintf(stderr, " hsr | macsec | netdevsim\n");
exit(-1);
}
"mtu", "mtu %u ",
rta_getattr_u32(tb[IFLA_MTU]));
if (tb[IFLA_XDP])
- xdp_dump(fp, tb[IFLA_XDP]);
+ xdp_dump(fp, tb[IFLA_XDP], do_link, false);
if (tb[IFLA_QDISC])
print_string(PRINT_ANY,
"qdisc",
}
}
-
if ((do_link || show_details) && tb[IFLA_IFALIAS]) {
print_string(PRINT_FP, NULL, "%s ", _SL_);
print_string(PRINT_ANY,
rta_getattr_str(tb[IFLA_IFALIAS]));
}
+ if ((do_link || show_details) && tb[IFLA_XDP])
+ xdp_dump(fp, tb[IFLA_XDP], true, true);
+
if (do_link && show_stats) {
print_string(PRINT_FP, NULL, "%s", _SL_);
__print_link_stats(fp, tb);
format_host_rta(ifa->ifa_family,
rta_tb[IFA_ADDRESS]));
}
- print_int(PRINT_ANY, "prefixlen", "/%d", ifa->ifa_prefixlen);
+ print_int(PRINT_ANY, "prefixlen", "/%d ", ifa->ifa_prefixlen);
}
if (brief)
{
struct ifaddrmsg *ifa = NLMSG_DATA(n);
- printf("if%d:\n", ifa->ifa_index);
+ open_json_object(NULL);
+ print_int(PRINT_ANY, "index", "if%d:\n", ifa->ifa_index);
print_addrinfo(NULL, n, stdout);
+ close_json_object();
return 0;
}
static int ipaddr_showdump(void)
{
+ int err;
+
if (ipadd_dump_check_magic())
exit(-1);
- exit(rtnl_from_file(stdin, &show_handler, NULL));
+ new_json_obj(json);
+ open_json_object(NULL);
+ open_json_array(PRINT_JSON, "addr_info");
+
+ err = rtnl_from_file(stdin, &show_handler, NULL);
+
+ close_json_array(PRINT_JSON, NULL);
+ close_json_object();
+ delete_json_obj();
+
+ exit(err);
}
static int restore_handler(const struct sockaddr_nl *nl,
ll_init_map(&rth);
- ret = rtnl_talk(&rth, n, n, sizeof(*n));
+ ret = rtnl_talk(&rth, n, NULL);
if ((ret < 0) && (errno == EEXIST))
ret = 0;
* Initialize a json_writer and open an array object
* if -json was specified.
*/
- new_json_obj(json, stdout);
+ new_json_obj(json);
/*
* If only filter_dev present and none of the other
return -1;
}
- if (rtnl_talk(&rth, &req.n, NULL, 0) < 0)
+ if (rtnl_talk(&rth, &req.n, NULL) < 0)
return -2;
return 0;