X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ip%2Fip.c;h=e4131714018f9a843a02cbff2fa9054eae75e75d;hb=25c6339b223f17d1603702c0c87f06b252bb4949;hp=e75447e1bdfd0dda9086d1c43872a153cbccfa50;hpb=142434dc512fa62e32af3a82fffdd9862d44cb9c;p=mirror_iproute2.git diff --git a/ip/ip.c b/ip/ip.c index e75447e1..e4131714 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -30,10 +29,10 @@ int human_readable; int use_iec; int show_stats; int show_details; -int resolve_hosts; int oneline; +int brief; +int json; int timestamp; -const char *_SL_; int force; int max_flush_loops = 10; int batch_mode; @@ -48,16 +47,17 @@ static void usage(void) fprintf(stderr, "Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n" " ip [ -force ] -batch filename\n" -"where OBJECT := { link | address | addrlabel | route | rule | neighbor | ntable |\n" +"where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |\n" " tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |\n" -" netns | l2tp | fou | tcp_metrics | token | netconf }\n" +" netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |\n" +" vrf | sr }\n" " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n" -" -h[uman-readable] | -iec |\n" -" -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |\n" -" -4 | -6 | -I | -D | -B | -0 |\n" -" -l[oops] { maximum-addr-flush-attempts } |\n" +" -h[uman-readable] | -iec | -j[son] | -p[retty] |\n" +" -f[amily] { inet | inet6 | mpls | bridge | link } |\n" +" -4 | -6 | -I | -D | -M | -B | -0 |\n" +" -l[oops] { maximum-addr-flush-attempts } | -br[ief] |\n" " -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |\n" -" -rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}\n"); +" -rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}\n"); exit(-1); } @@ -83,6 +83,8 @@ static const struct cmd { { "link", do_iplink }, { "l2tp", do_ipl2tp }, { "fou", do_ipfou }, + { "ila", do_ipila }, + { "macsec", do_ipmacsec }, { "tunnel", do_iptunnel }, { "tunl", do_iptunnel }, { "tuntap", do_iptuntap }, @@ -96,6 +98,8 @@ static const struct cmd { { "mrule", do_multirule }, { "netns", do_netns }, { "netconf", do_ipnetconf }, + { "vrf", do_ipvrf}, + { "sr", do_seg6 }, { "help", do_help }, { 0 } }; @@ -167,6 +171,19 @@ int main(int argc, char **argv) { char *basename; char *batch_file = NULL; + int color = 0; + + /* to run vrf exec without root, capabilities might be set, drop them + * if not needed as the first thing. + * execv will drop them for the child command. + * vrf exec requires: + * - cap_dac_override to create the cgroup subdir in /sys + * - cap_sys_admin to load the BPF program + * - cap_net_admin to set the socket into the cgroup + */ + if (argc < 3 || strcmp(argv[1], "vrf") != 0 || + strcmp(argv[2], "exec") != 0) + drop_cap(); basename = strrchr(argv[0], '/'); if (basename == NULL) @@ -208,8 +225,6 @@ int main(int argc, char **argv) preferred_family = AF_INET6; } else if (strcmp(opt, "-0") == 0) { preferred_family = AF_PACKET; - } else if (strcmp(opt, "-I") == 0) { - preferred_family = AF_IPX; } else if (strcmp(opt, "-D") == 0) { preferred_family = AF_DECnet; } else if (strcmp(opt, "-M") == 0) { @@ -235,10 +250,6 @@ int main(int argc, char **argv) } else if (matches(opt, "-tshort") == 0) { ++timestamp; ++timestamp_short; -#if 0 - } else if (matches(opt, "-numeric") == 0) { - rtnl_names_numeric++; -#endif } else if (matches(opt, "-Version") == 0) { printf("ip utility, iproute2-ss%s\n", SNAPSHOT); exit(0); @@ -250,6 +261,12 @@ int main(int argc, char **argv) if (argc <= 1) usage(); batch_file = argv[1]; + } else if (matches(opt, "-brief") == 0) { + ++brief; + } else if (matches(opt, "-json") == 0) { + ++json; + } else if (matches(opt, "-pretty") == 0) { + ++pretty; } else if (matches(opt, "-rcvbuf") == 0) { unsigned int size; @@ -263,8 +280,7 @@ int main(int argc, char **argv) exit(-1); } rcvbuf = size; - } else if (matches(opt, "-color") == 0) { - enable_color(); + } else if (matches_color(opt, &color)) { } else if (matches(opt, "-help") == 0) { usage(); } else if (matches(opt, "-netns") == 0) { @@ -284,12 +300,16 @@ int main(int argc, char **argv) _SL_ = oneline ? "\\" : "\n"; + check_enable_color(color, json); + if (batch_file) return batch(batch_file); if (rtnl_open(&rth, 0) < 0) exit(1); + rtnl_set_strict_dump(&rth); + if (strlen(basename) > 2) return do_cmd(basename+2, argc, argv);