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; ...@@ -19,6 +19,7 @@ extern int show_details;
extern int show_raw; extern int show_raw;
extern int resolve_hosts; extern int resolve_hosts;
extern int oneline; extern int oneline;
extern int brief;
extern int timestamp; extern int timestamp;
extern int timestamp_short; extern int timestamp_short;
extern const char * _SL_; extern const char * _SL_;
......
...@@ -32,6 +32,7 @@ int show_stats; ...@@ -32,6 +32,7 @@ int show_stats;
int show_details; int show_details;
int resolve_hosts; int resolve_hosts;
int oneline; int oneline;
int brief;
int timestamp; int timestamp;
const char *_SL_; const char *_SL_;
int force; int force;
...@@ -55,7 +56,7 @@ static void usage(void) ...@@ -55,7 +56,7 @@ static void usage(void)
" -h[uman-readable] | -iec |\n" " -h[uman-readable] | -iec |\n"
" -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |\n" " -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |\n"
" -4 | -6 | -I | -D | -B | -0 |\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" " -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); exit(-1);
...@@ -250,6 +251,8 @@ int main(int argc, char **argv) ...@@ -250,6 +251,8 @@ int main(int argc, char **argv)
if (argc <= 1) if (argc <= 1)
usage(); usage();
batch_file = argv[1]; batch_file = argv[1];
} else if (matches(opt, "-brief") == 0) {
++brief;
} else if (matches(opt, "-rcvbuf") == 0) { } else if (matches(opt, "-rcvbuf") == 0) {
unsigned int size; unsigned int size;
......
...@@ -2,6 +2,9 @@ extern int get_operstate(const char *name); ...@@ -2,6 +2,9 @@ extern int get_operstate(const char *name);
extern int print_linkinfo(const struct sockaddr_nl *who, extern int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n, struct nlmsghdr *n,
void *arg); 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, extern int print_addrinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n, struct nlmsghdr *n,
void *arg); void *arg);
......
...@@ -138,13 +138,22 @@ static void print_operstate(FILE *f, __u8 state) ...@@ -138,13 +138,22 @@ static void print_operstate(FILE *f, __u8 state)
if (state >= sizeof(oper_states)/sizeof(oper_states[0])) if (state >= sizeof(oper_states)/sizeof(oper_states[0]))
fprintf(f, "state %#x ", state); fprintf(f, "state %#x ", state);
else { else {
fprintf(f, "state "); if (brief) {
if (strcmp(oper_states[state], "UP") == 0) if (strcmp(oper_states[state], "UP") == 0)
color_fprintf(f, COLOR_OPERSTATE_UP, "%s ", oper_states[state]); color_fprintf(f, COLOR_OPERSTATE_UP, "%-14s ", oper_states[state]);
else if (strcmp(oper_states[state], "DOWN") == 0) else if (strcmp(oper_states[state], "DOWN") == 0)
color_fprintf(f, COLOR_OPERSTATE_DOWN, "%s ", oper_states[state]); color_fprintf(f, COLOR_OPERSTATE_DOWN, "%-14s ", oper_states[state]);
else else
fprintf(f, "%s ", oper_states[state]); 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]);
else if (strcmp(oper_states[state], "DOWN") == 0)
color_fprintf(f, COLOR_OPERSTATE_DOWN, "%s ", oper_states[state]);
else
fprintf(f, "%s ", oper_states[state]);
}
} }
} }
...@@ -590,6 +599,88 @@ static void print_link_stats(FILE *fp, struct nlmsghdr *n) ...@@ -590,6 +599,88 @@ static void print_link_stats(FILE *fp, struct nlmsghdr *n)
fprintf(fp, "%s", _SL_); 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, int print_linkinfo(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg) struct nlmsghdr *n, void *arg)
{ {
...@@ -892,18 +983,20 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -892,18 +983,20 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
if (n->nlmsg_type == RTM_DELADDR) if (n->nlmsg_type == RTM_DELADDR)
fprintf(fp, "Deleted "); fprintf(fp, "Deleted ");
if (filter.oneline || filter.flushb) if (!brief) {
fprintf(fp, "%u: %s", ifa->ifa_index, ll_index_to_name(ifa->ifa_index)); if (filter.oneline || filter.flushb)
if (ifa->ifa_family == AF_INET) fprintf(fp, "%u: %s", ifa->ifa_index, ll_index_to_name(ifa->ifa_index));
fprintf(fp, " inet "); if (ifa->ifa_family == AF_INET)
else if (ifa->ifa_family == AF_INET6) fprintf(fp, " inet ");
fprintf(fp, " inet6 "); else if (ifa->ifa_family == AF_INET6)
else if (ifa->ifa_family == AF_DECnet) fprintf(fp, " inet6 ");
fprintf(fp, " dnet "); else if (ifa->ifa_family == AF_DECnet)
else if (ifa->ifa_family == AF_IPX) fprintf(fp, " dnet ");
fprintf(fp, " ipx "); else if (ifa->ifa_family == AF_IPX)
else fprintf(fp, " ipx ");
fprintf(fp, " family %d ", ifa->ifa_family); else
fprintf(fp, " family %d ", ifa->ifa_family);
}
if (rta_tb[IFA_LOCAL]) { if (rta_tb[IFA_LOCAL]) {
if (ifa->ifa_family == AF_INET) if (ifa->ifa_family == AF_INET)
...@@ -936,6 +1029,9 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -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]) { if (rta_tb[IFA_BROADCAST]) {
fprintf(fp, "brd %s ", fprintf(fp, "brd %s ",
format_host(ifa->ifa_family, format_host(ifa->ifa_family,
...@@ -1018,6 +1114,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, ...@@ -1018,6 +1114,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
} }
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
brief_exit:
fflush(fp); fflush(fp);
return 0; return 0;
} }
...@@ -1078,6 +1175,10 @@ static int print_selected_addrinfo(struct ifinfomsg *ifi, ...@@ -1078,6 +1175,10 @@ static int print_selected_addrinfo(struct ifinfomsg *ifi,
print_addrinfo(NULL, n, fp); print_addrinfo(NULL, n, fp);
} }
if (brief) {
fprintf(fp, "\n");
fflush(fp);
}
return 0; return 0;
} }
...@@ -1539,9 +1640,16 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action) ...@@ -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) { for (l = linfo.head; l; l = l->next) {
int res = 0; int res = 0;
struct ifinfomsg *ifi = NLMSG_DATA(&l->h);
if (no_link || (res = print_linkinfo(NULL, &l->h, stdout)) >= 0) { if (brief) {
struct ifinfomsg *ifi = NLMSG_DATA(&l->h); 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) if (filter.family != AF_PACKET)
print_selected_addrinfo(ifi, print_selected_addrinfo(ifi,
ainfo.head, stdout); ainfo.head, stdout);
......
This diff is collapsed.
...@@ -21,7 +21,8 @@ ip-link \- network device configuration ...@@ -21,7 +21,8 @@ ip-link \- network device configuration
\fB\-r\fR[\fIesolve\fR] | \fB\-r\fR[\fIesolve\fR] |
\fB\-f\fR[\fIamily\fR] { \fB\-f\fR[\fIamily\fR] {
.BR inet " | " inet6 " | " ipx " | " dnet " | " link " } | " .BR inet " | " inet6 " | " ipx " | " dnet " | " link " } | "
\fB\-o\fR[\fIneline\fR] } \fB\-o\fR[\fIneline\fR] |
\fB\-br\fR[\fIief\fR] }
.ti -8 .ti -8
.BI "ip link add" .BI "ip link add"
...@@ -351,10 +352,30 @@ where <phy_dev> is the physical device to which VLAN device is bound. ...@@ -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. - specifies whether the VLAN device state is bound to the physical device state.
.BI ingress-qos-map " QOS-MAP " .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 " .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 .in -8
.TP .TP
...@@ -1098,7 +1119,8 @@ IEEE 802.15.4 device wpan0. ...@@ -1098,7 +1119,8 @@ IEEE 802.15.4 device wpan0.
.br .br
.BR ip (8), .BR ip (8),
.BR ip-netns (8), .BR ip-netns (8),
.BR ethtool (8) .BR ethtool (8),
.BR iptables (8)
.SH AUTHOR .SH AUTHOR
Original Manpage by Michail Litvak <mci@owl.openwall.com> Original Manpage by Michail Litvak <mci@owl.openwall.com>
...@@ -6,14 +6,12 @@ ip-tunnel - tunnel configuration ...@@ -6,14 +6,12 @@ ip-tunnel - tunnel configuration
.ad l .ad l
.in +8 .in +8
.ti -8 .ti -8
.B ip .B ip tunnel help
.RI "[ " OPTIONS " ]"
.B tunnel
.RI " { " COMMAND " | "
.BR help " }"
.sp .sp
.ti -8 .ti -8
.BR "ip tunnel" " { " add " | " change " | " del " | " show " | " prl " }" .BR "ip "
.RI "[ " OPTIONS " ]"
.BR "tunnel" " { " add " | " change " | " del " | " show " | " prl " }"
.RI "[ " NAME " ]" .RI "[ " NAME " ]"
.br .br
.RB "[ " mode .RB "[ " mode
...@@ -29,7 +27,7 @@ ip-tunnel - tunnel configuration ...@@ -29,7 +27,7 @@ ip-tunnel - tunnel configuration
.br .br
.RB "[ " encaplimit .RB "[ " encaplimit
.IR ELIM " ]" .IR ELIM " ]"
.RB "[ " ttl .RB "[ " ttl "|" hoplimit
.IR TTL " ]" .IR TTL " ]"
.br .br
.RB "[ " tos .RB "[ " tos
...@@ -50,7 +48,7 @@ ip-tunnel - tunnel configuration ...@@ -50,7 +48,7 @@ ip-tunnel - tunnel configuration
.ti -8 .ti -8
.IR MODE " := " .IR MODE " := "
.RB " { " ipip " | " gre " | " sit " | " isatap " | " ip6ip6 " | " ipip6 " | " ip6gre " | " any " }" .RB " { " ipip " | " gre " | " sit " | " isatap " | " vti " | " ip6ip6 " | " ipip6 " | " ip6gre " | " vti6 " | " any " }"
.ti -8 .ti -8
.IR ADDR " := { " IP_ADDRESS " |" .IR ADDR " := { " IP_ADDRESS " |"
...@@ -107,10 +105,10 @@ select the tunnel device name. ...@@ -107,10 +105,10 @@ select the tunnel device name.
set the tunnel mode. Available modes depend on the encapsulating address family. set the tunnel mode. Available modes depend on the encapsulating address family.
.br .br
Modes for IPv4 encapsulation available: Modes for IPv4 encapsulation available:
.BR ipip ", " sit ", " isatap " and " gre "." .BR ipip ", " sit ", " isatap ", " vti ", and " gre "."
.br .br
Modes for IPv6 encapsulation available: Modes for IPv6 encapsulation available:
.BR ip6ip6 ", " ipip6 ", " ip6gre ", and " any "." .BR ip6ip6 ", " ipip6 ", " ip6gre ", " vti6 ", and " any "."
.TP .TP
.BI remote " ADDRESS" .BI remote " ADDRESS"
...@@ -123,7 +121,9 @@ It must be an address on another interface of this host. ...@@ -123,7 +121,9 @@ It must be an address on another interface of this host.
.TP .TP
.BI ttl " N" .BI ttl " N"
set a fixed TTL .TP
.BI hoplimit " N"
set a fixed TTL (IPv4) or hoplimit (IPv6)
.I N .I N
on tunneled packets. on tunneled packets.
.I N .I N
...@@ -218,7 +218,7 @@ The ...@@ -218,7 +218,7 @@ The
.B seq .B seq
flag is equivalent to the combination flag is equivalent to the combination
.BR "iseq oseq" . .BR "iseq oseq" .
.B It isn't work. Don't use it. .B It doesn't work. Don't use it.
.TP .TP
.BI encaplim " ELIM" .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