Merge branch 'master' into next
Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
commit
830ac9abe6
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -18,11 +19,12 @@
|
|||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#define _LINUX_SYSINFO_H /* avoid collision with musl header */
|
||||
#include <linux/genetlink.h>
|
||||
#include <linux/devlink.h>
|
||||
#include <libmnl/libmnl.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include "SNAPSHOT.h"
|
||||
|
|
@ -48,32 +50,53 @@
|
|||
#define HEALTH_REPORTER_TIMESTAMP_FMT_LEN 80
|
||||
|
||||
static int g_new_line_count;
|
||||
|
||||
#define pr_err(args...) fprintf(stderr, ##args)
|
||||
#define pr_out(args...) \
|
||||
do { \
|
||||
if (g_indent_newline) { \
|
||||
fprintf(stdout, "%s", g_indent_str); \
|
||||
g_indent_newline = false; \
|
||||
} \
|
||||
fprintf(stdout, ##args); \
|
||||
g_new_line_count = 0; \
|
||||
} while (0)
|
||||
|
||||
#define pr_out_sp(num, args...) \
|
||||
do { \
|
||||
int ret = fprintf(stdout, ##args); \
|
||||
if (ret < num) \
|
||||
fprintf(stdout, "%*s", num - ret, ""); \
|
||||
g_new_line_count = 0; \
|
||||
} while (0)
|
||||
|
||||
static int g_indent_level;
|
||||
static bool g_indent_newline;
|
||||
|
||||
#define INDENT_STR_STEP 2
|
||||
#define INDENT_STR_MAXLEN 32
|
||||
static char g_indent_str[INDENT_STR_MAXLEN + 1] = "";
|
||||
|
||||
static void __attribute__((format(printf, 1, 2)))
|
||||
pr_err(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void __attribute__((format(printf, 1, 2)))
|
||||
pr_out(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (g_indent_newline) {
|
||||
printf("%s", g_indent_str);
|
||||
g_indent_newline = false;
|
||||
}
|
||||
va_start(ap, fmt);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
g_new_line_count = 0;
|
||||
}
|
||||
|
||||
static void __attribute__((format(printf, 2, 3)))
|
||||
pr_out_sp(unsigned int num, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (ret < num)
|
||||
printf("%*s", num - ret, "");
|
||||
g_new_line_count = 0; \
|
||||
}
|
||||
|
||||
static void __pr_out_indent_inc(void)
|
||||
{
|
||||
if (g_indent_level + INDENT_STR_STEP > INDENT_STR_MAXLEN)
|
||||
|
|
@ -1726,9 +1749,9 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val)
|
|||
jsonw_u64_field(dl->jw, name, val);
|
||||
} else {
|
||||
if (g_indent_newline)
|
||||
pr_out("%s %lu", name, val);
|
||||
pr_out("%s %"PRIu64, name, val);
|
||||
else
|
||||
pr_out(" %s %lu", name, val);
|
||||
pr_out(" %s %"PRIu64, name, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1753,7 +1776,7 @@ static void pr_out_uint64_value(struct dl *dl, uint64_t value)
|
|||
if (dl->json_output)
|
||||
jsonw_u64(dl->jw, value);
|
||||
else
|
||||
pr_out(" %lu", value);
|
||||
pr_out(" %"PRIu64, value);
|
||||
}
|
||||
|
||||
static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
static const char SNAPSHOT[] = "190510";
|
||||
static const char SNAPSHOT[] = "190708";
|
||||
|
|
|
|||
|
|
@ -206,6 +206,24 @@ enum xtables_ext_flags {
|
|||
XTABLES_EXT_ALIAS = 1 << 0,
|
||||
};
|
||||
|
||||
#if XTABLES_VERSION_CODE >= 12
|
||||
struct xt_xlate;
|
||||
|
||||
struct xt_xlate_mt_params {
|
||||
const void *ip;
|
||||
const struct xt_entry_match *match;
|
||||
int numeric;
|
||||
bool escape_quotes;
|
||||
};
|
||||
|
||||
struct xt_xlate_tg_params {
|
||||
const void *ip;
|
||||
const struct xt_entry_target *target;
|
||||
int numeric;
|
||||
bool escape_quotes;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Include file for additions: new matches and targets. */
|
||||
struct xtables_match
|
||||
{
|
||||
|
|
@ -270,6 +288,12 @@ struct xtables_match
|
|||
void (*x6_fcheck)(struct xt_fcheck_call *);
|
||||
const struct xt_option_entry *x6_options;
|
||||
|
||||
#if XTABLES_VERSION_CODE >= 12
|
||||
/* Translate iptables to nft */
|
||||
int (*xlate)(struct xt_xlate *xl,
|
||||
const struct xt_xlate_mt_params *params);
|
||||
#endif
|
||||
|
||||
/* Size of per-extension instance extra "global" scratch space */
|
||||
size_t udata_size;
|
||||
|
||||
|
|
@ -347,6 +371,12 @@ struct xtables_target
|
|||
void (*x6_fcheck)(struct xt_fcheck_call *);
|
||||
const struct xt_option_entry *x6_options;
|
||||
|
||||
#if XTABLES_VERSION_CODE >= 12
|
||||
/* Translate iptables to nft */
|
||||
int (*xlate)(struct xt_xlate *xl,
|
||||
const struct xt_xlate_tg_params *params);
|
||||
#endif
|
||||
|
||||
size_t udata_size;
|
||||
|
||||
/* Ignore these men behind the curtain: */
|
||||
|
|
|
|||
|
|
@ -2278,11 +2278,20 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
|
|||
if (set_lifetime(&preferred_lft, *argv))
|
||||
invarg("preferred_lft value", *argv);
|
||||
} else if (strcmp(*argv, "home") == 0) {
|
||||
ifa_flags |= IFA_F_HOMEADDRESS;
|
||||
if (req.ifa.ifa_family == AF_INET6)
|
||||
ifa_flags |= IFA_F_HOMEADDRESS;
|
||||
else
|
||||
fprintf(stderr, "Warning: home option can be set only for IPv6 addresses\n");
|
||||
} else if (strcmp(*argv, "nodad") == 0) {
|
||||
ifa_flags |= IFA_F_NODAD;
|
||||
if (req.ifa.ifa_family == AF_INET6)
|
||||
ifa_flags |= IFA_F_NODAD;
|
||||
else
|
||||
fprintf(stderr, "Warning: nodad option can be set only for IPv6 addresses\n");
|
||||
} else if (strcmp(*argv, "mngtmpaddr") == 0) {
|
||||
ifa_flags |= IFA_F_MANAGETEMPADDR;
|
||||
if (req.ifa.ifa_family == AF_INET6)
|
||||
ifa_flags |= IFA_F_MANAGETEMPADDR;
|
||||
else
|
||||
fprintf(stderr, "Warning: mngtmpaddr option can be set only for IPv6 addresses\n");
|
||||
} else if (strcmp(*argv, "noprefixroute") == 0) {
|
||||
ifa_flags |= IFA_F_NOPREFIXROUTE;
|
||||
} else if (strcmp(*argv, "autojoin") == 0) {
|
||||
|
|
|
|||
50
ip/iproute.c
50
ip/iproute.c
|
|
@ -1613,6 +1613,30 @@ static int save_route_prep(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int iproute_dump_filter(struct nlmsghdr *nlh, int reqlen)
|
||||
{
|
||||
struct rtmsg *rtm = NLMSG_DATA(nlh);
|
||||
int err;
|
||||
|
||||
rtm->rtm_protocol = filter.protocol;
|
||||
if (filter.cloned)
|
||||
rtm->rtm_flags |= RTM_F_CLONED;
|
||||
|
||||
if (filter.tb) {
|
||||
err = addattr32(nlh, reqlen, RTA_TABLE, filter.tb);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (filter.oif) {
|
||||
err = addattr32(nlh, reqlen, RTA_OIF, filter.oif);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iproute_flush(int family, rtnl_filter_t filter_fn)
|
||||
{
|
||||
time_t start = time(0);
|
||||
|
|
@ -1635,7 +1659,7 @@ static int iproute_flush(int family, rtnl_filter_t filter_fn)
|
|||
filter.flushe = sizeof(flushb);
|
||||
|
||||
for (;;) {
|
||||
if (rtnl_routedump_req(&rth, family, NULL) < 0) {
|
||||
if (rtnl_routedump_req(&rth, family, iproute_dump_filter) < 0) {
|
||||
perror("Cannot send dump request");
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -1675,30 +1699,6 @@ static int iproute_flush(int family, rtnl_filter_t filter_fn)
|
|||
}
|
||||
}
|
||||
|
||||
static int iproute_dump_filter(struct nlmsghdr *nlh, int reqlen)
|
||||
{
|
||||
struct rtmsg *rtm = NLMSG_DATA(nlh);
|
||||
int err;
|
||||
|
||||
rtm->rtm_protocol = filter.protocol;
|
||||
if (filter.cloned)
|
||||
rtm->rtm_flags |= RTM_F_CLONED;
|
||||
|
||||
if (filter.tb) {
|
||||
err = addattr32(nlh, reqlen, RTA_TABLE, filter.tb);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (filter.oif) {
|
||||
err = addattr32(nlh, reqlen, RTA_OIF, filter.oif);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iproute_list_flush_or_save(int argc, char **argv, int action)
|
||||
{
|
||||
int dump_family = preferred_family;
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ static int print_token(struct nlmsghdr *n, void *arg)
|
|||
return -1;
|
||||
|
||||
if (ifi->ifi_family != AF_INET6)
|
||||
return -1;
|
||||
return 0;
|
||||
if (ifi->ifi_index == 0)
|
||||
return -1;
|
||||
return 0;
|
||||
if (ifindex > 0 && ifi->ifi_index != ifindex)
|
||||
return 0;
|
||||
if (ifi->ifi_flags & (IFF_LOOPBACK | IFF_NOARP))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ Suppress header line.
|
|||
Print each socket's data on a single line.
|
||||
.TP
|
||||
.B \-n, \-\-numeric
|
||||
Do not try to resolve service names.
|
||||
Do not try to resolve service names. Show exact bandwidth values, instead of human-readable.
|
||||
.TP
|
||||
.B \-r, \-\-resolve
|
||||
Try to resolve numeric address/ports.
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ April 2005
|
|||
(http://devresources.linux-foundation.org/shemminger/netem/LCA2005_paper.pdf)
|
||||
|
||||
.IP " 2. " 4
|
||||
Netem page from Linux foundation, (http://www.linuxfoundation.org/en/Net:Netem)
|
||||
Netem page from Linux foundation, (https://wiki.linuxfoundation.org/networking/netem)
|
||||
|
||||
.IP " 3. " 4
|
||||
Salsano S., Ludovici F., Ordine A., "Definition of a general and intuitive loss
|
||||
|
|
|
|||
|
|
@ -2361,7 +2361,9 @@ static int proc_inet_split_line(char *line, char **loc, char **rem, char **data)
|
|||
|
||||
static char *sprint_bw(char *buf, double bw)
|
||||
{
|
||||
if (bw > 1000000.)
|
||||
if (!resolve_services)
|
||||
sprintf(buf, "%.0f", bw);
|
||||
else if (bw > 1000000.)
|
||||
sprintf(buf, "%.1fM", bw / 1000000.);
|
||||
else if (bw > 1000.)
|
||||
sprintf(buf, "%.1fK", bw / 1000.);
|
||||
|
|
|
|||
|
|
@ -320,14 +320,17 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
|
|||
}
|
||||
|
||||
} else if (!strcmp(*argv, "gemodel")) {
|
||||
double p;
|
||||
|
||||
NEXT_ARG();
|
||||
if (get_percent(&gemodel.p, *argv)) {
|
||||
if (parse_percent(&p, *argv)) {
|
||||
explain1("loss gemodel p");
|
||||
return -1;
|
||||
}
|
||||
set_percent(&gemodel.p, p);
|
||||
|
||||
/* set defaults */
|
||||
set_percent(&gemodel.r, 1.);
|
||||
set_percent(&gemodel.r, 1. - p);
|
||||
set_percent(&gemodel.h, 0);
|
||||
set_percent(&gemodel.k1, 0);
|
||||
loss_type = NETEM_LOSS_GE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue