mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-11-06 21:07:59 +00:00
This patch avoids a full link wildump request when the user has specified
a single link. Uses RTM_GETLINK without the NLM_F_DUMP flag.
This helps on a system with large number of interfaces.
This patch currently only uses the link ifindex in the filter.
Hoping to provide a subsequent kernel patch to do link dump filtering on
other attributes in the kernel.
In iplink_get, to be safe, this patch currently sets the answer buffer
size to the max size that libnetlink rtnl_talk can copy. The current api
does not seem to provide a way to indicate the answer buf size.
changelog from RFC to v1:
- incorporated comments from stephen (fixed comment and fixed if/else block)
changelog from v1 to v2:
- fix whitespaces error
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
89 lines
3.2 KiB
C
89 lines
3.2 KiB
C
extern int get_operstate(const char *name);
|
|
extern int print_linkinfo(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n,
|
|
void *arg);
|
|
extern int print_addrinfo(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n,
|
|
void *arg);
|
|
extern int print_addrlabel(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_neigh(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_ntable(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int ipaddr_list(int argc, char **argv);
|
|
extern int ipaddr_list_link(int argc, char **argv);
|
|
extern int iproute_monitor(int argc, char **argv);
|
|
extern void iplink_usage(void) __attribute__((noreturn));
|
|
extern void iproute_reset_filter(void);
|
|
extern void ipmroute_reset_filter(void);
|
|
void ipaddr_get_vf_rate(int, int *, int *, int);
|
|
extern void ipaddr_reset_filter(int);
|
|
extern void ipneigh_reset_filter(void);
|
|
extern void ipntable_reset_filter(void);
|
|
extern int print_route(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_mroute(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_prefix(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_rule(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int print_netconf(const struct sockaddr_nl *who,
|
|
struct nlmsghdr *n, void *arg);
|
|
extern int do_ipaddr(int argc, char **argv);
|
|
extern int do_ipaddrlabel(int argc, char **argv);
|
|
extern int do_iproute(int argc, char **argv);
|
|
extern int do_iprule(int argc, char **argv);
|
|
extern int do_ipneigh(int argc, char **argv);
|
|
extern int do_ipntable(int argc, char **argv);
|
|
extern int do_iptunnel(int argc, char **argv);
|
|
extern int do_ip6tunnel(int argc, char **argv);
|
|
extern int do_iptuntap(int argc, char **argv);
|
|
extern int do_iplink(int argc, char **argv);
|
|
extern int do_ipmonitor(int argc, char **argv);
|
|
extern int do_multiaddr(int argc, char **argv);
|
|
extern int do_multiroute(int argc, char **argv);
|
|
extern int do_multirule(int argc, char **argv);
|
|
extern int do_netns(int argc, char **argv);
|
|
extern int do_xfrm(int argc, char **argv);
|
|
extern int do_ipl2tp(int argc, char **argv);
|
|
extern int do_tcp_metrics(int argc, char **argv);
|
|
extern int do_ipnetconf(int argc, char **argv);
|
|
extern int do_iptoken(int argc, char **argv);
|
|
extern int iplink_get(unsigned int flags, char *name, __u32 filt_mask);
|
|
|
|
static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb)
|
|
{
|
|
__u32 table = r->rtm_table;
|
|
if (tb[RTA_TABLE])
|
|
table = rta_getattr_u32(tb[RTA_TABLE]);
|
|
return table;
|
|
}
|
|
|
|
extern struct rtnl_handle rth;
|
|
|
|
#include <stdbool.h>
|
|
|
|
struct link_util
|
|
{
|
|
struct link_util *next;
|
|
const char *id;
|
|
int maxattr;
|
|
int (*parse_opt)(struct link_util *, int, char **,
|
|
struct nlmsghdr *);
|
|
void (*print_opt)(struct link_util *, FILE *,
|
|
struct rtattr *[]);
|
|
void (*print_xstats)(struct link_util *, FILE *,
|
|
struct rtattr *);
|
|
bool slave;
|
|
};
|
|
|
|
struct link_util *get_link_kind(const char *kind);
|
|
struct link_util *get_link_slave_kind(const char *slave_kind);
|
|
int get_netns_fd(const char *name);
|
|
|
|
#ifndef INFINITY_LIFE_TIME
|
|
#define INFINITY_LIFE_TIME 0xFFFFFFFFU
|
|
#endif
|