Commit f1e225be authored by Stephen Hemminger's avatar Stephen Hemminger

Merge branch 'master' into net-next

parents 15faa0a3 ec4ef6ae
static const char SNAPSHOT[] = "150626";
static const char SNAPSHOT[] = "150831";
......@@ -19,6 +19,7 @@ extern int show_details;
extern int show_raw;
extern int resolve_hosts;
extern int oneline;
extern int brief;
extern int timestamp;
extern int timestamp_short;
extern const char * _SL_;
......
......@@ -32,6 +32,7 @@ int show_stats;
int show_details;
int resolve_hosts;
int oneline;
int brief;
int timestamp;
const char *_SL_;
int force;
......@@ -55,7 +56,7 @@ static void usage(void)
" -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"
" -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");
exit(-1);
......@@ -250,6 +251,8 @@ 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, "-rcvbuf") == 0) {
unsigned int size;
......
......@@ -2,6 +2,9 @@ extern int get_operstate(const char *name);
extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
extern int print_linkinfo_brief(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
extern int print_addrinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n,
void *arg);
......
......@@ -138,6 +138,14 @@ static void print_operstate(FILE *f, __u8 state)
if (state >= sizeof(oper_states)/sizeof(oper_states[0]))
fprintf(f, "state %#x ", state);
else {
if (brief) {
if (strcmp(oper_states[state], "UP") == 0)
color_fprintf(f, COLOR_OPERSTATE_UP, "%-14s ", oper_states[state]);
else if (strcmp(oper_states[state], "DOWN") == 0)
color_fprintf(f, COLOR_OPERSTATE_DOWN, "%-14s ", oper_states[state]);
else
fprintf(f, "%-14s ", oper_states[state]);
} else {
fprintf(f, "state ");
if (strcmp(oper_states[state], "UP") == 0)
color_fprintf(f, COLOR_OPERSTATE_UP, "%s ", oper_states[state]);
......@@ -146,6 +154,7 @@ static void print_operstate(FILE *f, __u8 state)
else
fprintf(f, "%s ", oper_states[state]);
}
}
}
int get_operstate(const char *name)
......@@ -590,6 +599,88 @@ static void print_link_stats(FILE *fp, struct nlmsghdr *n)
fprintf(fp, "%s", _SL_);
}
int print_linkinfo_brief(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
struct ifinfomsg *ifi = NLMSG_DATA(n);
struct rtattr * tb[IFLA_MAX+1];
int len = n->nlmsg_len;
char *name;
char buf[32] = { 0, };
unsigned m_flag = 0;
if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK)
return -1;
len -= NLMSG_LENGTH(sizeof(*ifi));
if (len < 0)
return -1;
if (filter.ifindex && ifi->ifi_index != filter.ifindex)
return -1;
if (filter.up && !(ifi->ifi_flags&IFF_UP))
return -1;
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
if (tb[IFLA_IFNAME] == NULL) {
fprintf(stderr, "BUG: device with ifindex %d has nil ifname\n", ifi->ifi_index);
}
if (filter.label &&
(!filter.family || filter.family == AF_PACKET) &&
fnmatch(filter.label, RTA_DATA(tb[IFLA_IFNAME]), 0))
return -1;
if (tb[IFLA_GROUP]) {
int group = *(int*)RTA_DATA(tb[IFLA_GROUP]);
if (filter.group != -1 && group != filter.group)
return -1;
}
if (n->nlmsg_type == RTM_DELLINK)
fprintf(fp, "Deleted ");
name = (char *)(tb[IFLA_IFNAME] ? rta_getattr_str(tb[IFLA_IFNAME]) : "<nil>");
if (tb[IFLA_LINK]) {
SPRINT_BUF(b1);
int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]);
if (iflink == 0)
snprintf(buf, sizeof(buf), "%s@NONE", name);
else {
snprintf(buf, sizeof(buf),
"%s@%s", name, ll_idx_n2a(iflink, b1));
m_flag = ll_index_to_flags(iflink);
m_flag = !(m_flag & IFF_UP);
}
} else
snprintf(buf, sizeof(buf), "%s", name);
fprintf(fp, "%-16s ", buf);
if (tb[IFLA_OPERSTATE])
print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));
if (filter.family == AF_PACKET) {
SPRINT_BUF(b1);
if (tb[IFLA_ADDRESS]) {
color_fprintf(fp, COLOR_MAC, "%s ",
ll_addr_n2a(RTA_DATA(tb[IFLA_ADDRESS]),
RTA_PAYLOAD(tb[IFLA_ADDRESS]),
ifi->ifi_type,
b1, sizeof(b1)));
}
}
if (filter.family == AF_PACKET)
print_link_flags(fp, ifi->ifi_flags, m_flag);
if (filter.family == AF_PACKET)
fprintf(fp, "\n");
fflush(fp);
return 0;
}
int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
......@@ -892,6 +983,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
if (n->nlmsg_type == RTM_DELADDR)
fprintf(fp, "Deleted ");
if (!brief) {
if (filter.oneline || filter.flushb)
fprintf(fp, "%u: %s", ifa->ifa_index, ll_index_to_name(ifa->ifa_index));
if (ifa->ifa_family == AF_INET)
......@@ -904,6 +996,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
fprintf(fp, " ipx ");
else
fprintf(fp, " family %d ", ifa->ifa_family);
}
if (rta_tb[IFA_LOCAL]) {
if (ifa->ifa_family == AF_INET)
......@@ -936,6 +1029,9 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
}
}
if (brief)
goto brief_exit;
if (rta_tb[IFA_BROADCAST]) {
fprintf(fp, "brd %s ",
format_host(ifa->ifa_family,
......@@ -1018,6 +1114,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
}
}
fprintf(fp, "\n");
brief_exit:
fflush(fp);
return 0;
}
......@@ -1078,6 +1175,10 @@ static int print_selected_addrinfo(struct ifinfomsg *ifi,
print_addrinfo(NULL, n, fp);
}
if (brief) {
fprintf(fp, "\n");
fflush(fp);
}
return 0;
}
......@@ -1539,9 +1640,16 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
for (l = linfo.head; l; l = l->next) {
int res = 0;
if (no_link || (res = print_linkinfo(NULL, &l->h, stdout)) >= 0) {
struct ifinfomsg *ifi = NLMSG_DATA(&l->h);
if (brief) {
if (print_linkinfo_brief(NULL, &l->h, stdout) == 0)
if (filter.family != AF_PACKET)
print_selected_addrinfo(ifi,
ainfo.head,
stdout);
} else if (no_link ||
(res = print_linkinfo(NULL, &l->h, stdout)) >= 0) {
if (filter.family != AF_PACKET)
print_selected_addrinfo(ifi,
ainfo.head, stdout);
......
This diff is collapsed.
......@@ -21,7 +21,8 @@ ip-link \- network device configuration
\fB\-r\fR[\fIesolve\fR] |
\fB\-f\fR[\fIamily\fR] {
.BR inet " | " inet6 " | " ipx " | " dnet " | " link " } | "
\fB\-o\fR[\fIneline\fR] }
\fB\-o\fR[\fIneline\fR] |
\fB\-br\fR[\fIief\fR] }
.ti -8
.BI "ip link add"
......@@ -351,10 +352,30 @@ where <phy_dev> is the physical device to which VLAN device is bound.
- specifies whether the VLAN device state is bound to the physical device state.
.BI ingress-qos-map " QOS-MAP "
- defines a mapping between priority code points on incoming frames. The format is FROM:TO with multiple mappings separated by spaces.
- defines a mapping of VLAN header prio field to the Linux internal packet
priority on incoming frames. The format is FROM:TO with multiple mappings
separated by spaces.
.BI egress-qos-map " QOS-MAP "
- the same as ingress-qos-map but for outgoing frames.
- defines a mapping of Linux internal packet priority to VLAN header prio field
but for outgoing frames. The format is the same as for ingress-qos-map.
.in +4
Linux packet priority can be set by
.BR iptables "(8)":
.in +4
.sp
.B iptables
-t mangle -A POSTROUTING [...] -j CLASSIFY --set-class 0:4
.sp
.in -4
and this "4" priority can be used in the egress qos mapping to set VLAN prio "5":
.sp
.in +4
.B ip
link set veth0.10 type vlan egress 4:5
.in -4
.in -4
.in -8
.TP
......@@ -1098,7 +1119,8 @@ IEEE 802.15.4 device wpan0.
.br
.BR ip (8),
.BR ip-netns (8),
.BR ethtool (8)
.BR ethtool (8),
.BR iptables (8)
.SH AUTHOR
Original Manpage by Michail Litvak <mci@owl.openwall.com>
......@@ -6,14 +6,12 @@ ip-tunnel - tunnel configuration
.ad l
.in +8
.ti -8
.B ip
.RI "[ " OPTIONS " ]"
.B tunnel
.RI " { " COMMAND " | "
.BR help " }"
.B ip tunnel help
.sp
.ti -8
.BR "ip tunnel" " { " add " | " change " | " del " | " show " | " prl " }"
.BR "ip "
.RI "[ " OPTIONS " ]"
.BR "tunnel" " { " add " | " change " | " del " | " show " | " prl " }"
.RI "[ " NAME " ]"
.br
.RB "[ " mode
......@@ -29,7 +27,7 @@ ip-tunnel - tunnel configuration
.br
.RB "[ " encaplimit
.IR ELIM " ]"
.RB "[ " ttl
.RB "[ " ttl "|" hoplimit
.IR TTL " ]"
.br
.RB "[ " tos
......@@ -50,7 +48,7 @@ ip-tunnel - tunnel configuration
.ti -8
.IR MODE " := "
.RB " { " ipip " | " gre " | " sit " | " isatap " | " ip6ip6 " | " ipip6 " | " ip6gre " | " any " }"
.RB " { " ipip " | " gre " | " sit " | " isatap " | " vti " | " ip6ip6 " | " ipip6 " | " ip6gre " | " vti6 " | " any " }"
.ti -8
.IR ADDR " := { " IP_ADDRESS " |"
......@@ -107,10 +105,10 @@ select the tunnel device name.
set the tunnel mode. Available modes depend on the encapsulating address family.
.br
Modes for IPv4 encapsulation available:
.BR ipip ", " sit ", " isatap " and " gre "."
.BR ipip ", " sit ", " isatap ", " vti ", and " gre "."
.br
Modes for IPv6 encapsulation available:
.BR ip6ip6 ", " ipip6 ", " ip6gre ", and " any "."
.BR ip6ip6 ", " ipip6 ", " ip6gre ", " vti6 ", and " any "."
.TP
.BI remote " ADDRESS"
......@@ -123,7 +121,9 @@ It must be an address on another interface of this host.
.TP
.BI ttl " N"
set a fixed TTL
.TP
.BI hoplimit " N"
set a fixed TTL (IPv4) or hoplimit (IPv6)
.I N
on tunneled packets.
.I N
......@@ -218,7 +218,7 @@ The
.B seq
flag is equivalent to the combination
.BR "iseq oseq" .
.B It isn't work. Don't use it.
.B It doesn't work. Don't use it.
.TP
.BI encaplim " ELIM"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment