unsigned int groups;
unsigned int ifindex;
unsigned int master;
+ unsigned int proto;
} filter;
enum {
static void usage(void)
{
fprintf(stderr,
- "Usage: ip nexthop { list | flush } SELECTOR\n"
+ "Usage: ip nexthop { list | flush } [ protocol ID ] SELECTOR\n"
" ip nexthop { add | replace } id ID NH [ protocol ID ]\n"
" ip nexthop { get| del } id ID\n"
"SELECTOR := [ id ID ] [ dev DEV ] [ vrf NAME ] [ master DEV ]\n"
}
if (filter.groups) {
- addattr_l(nlh, reqlen, NHA_GROUPS, NULL, 0);
+ err = addattr_l(nlh, reqlen, NHA_GROUPS, NULL, 0);
if (err)
return err;
}
if (filter.master) {
- addattr32(nlh, reqlen, NHA_MASTER, filter.master);
+ err = addattr32(nlh, reqlen, NHA_MASTER, filter.master);
if (err)
return err;
}
return -1;
}
+ if (filter.proto && nhm->nh_protocol != filter.proto)
+ return 0;
+
parse_rtattr(tb, NHA_MAX, RTM_NHA(nhm), len);
if (tb[NHA_ID])
id = rta_getattr_u32(tb[NHA_ID]);
close_json_object();
}
+ print_string(PRINT_FP, NULL, "%s", " ");
close_json_array(PRINT_JSON, NULL);
}
return -1;
}
+ if (filter.proto && filter.proto != nhm->nh_protocol)
+ return 0;
+
parse_rtattr(tb, NHA_MAX, RTM_NHA(nhm), len);
open_json_object(NULL);
- if (n->nlmsg_type == RTM_DELROUTE)
+ if (n->nlmsg_type == RTM_DELNEXTHOP)
print_bool(PRINT_ANY, "deleted", "Deleted ", true);
if (tb[NHA_ID])
}
if (tb[NHA_BLACKHOLE])
- print_null(PRINT_ANY, "blackhole", "blackhole", NULL);
+ print_null(PRINT_ANY, "blackhole", "blackhole ", NULL);
if (nhm->nh_protocol != RTPROT_UNSPEC || show_details > 0) {
print_string(PRINT_ANY, "protocol", "proto %s ",
if (get_unsigned(&id, *argv, 0))
invarg("invalid id value", *argv);
return ipnh_get_id(id);
+ } else if (!matches(*argv, "protocol")) {
+ __u32 proto;
+
+ NEXT_ARG();
+ if (get_unsigned(&proto, *argv, 0))
+ invarg("invalid protocol value", *argv);
+ filter.proto = proto;
} else if (matches(*argv, "help") == 0) {
usage();
} else {