From 3462c116f8dd578591f5f41d249d7542ea476ca4 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 24 Jun 2016 12:14:23 +0200 Subject: [PATCH 1/6] man: ip-address, ip-link: Document 'type' quirk This covers the fact that calling 'ip {link|addr} show type foobar' does not return an error. Signed-off-by: Phil Sutter --- man/man8/ip-address.8.in | 6 ++++++ man/man8/ip-link.8.in | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in index ab0942d7..8d34adb3 100644 --- a/man/man8/ip-address.8.in +++ b/man/man8/ip-address.8.in @@ -280,6 +280,12 @@ only list interfaces enslaved to this master device. .BI type " TYPE" only list interfaces of the given type. +Note that the type name is not checked against the list of supported types - +instead it is sent as-is to the kernel. Later it is used to filter the returned +interface list by comparing it with the relevant attribute in case the kernel +didn't filter already. Therefore any string is accepted, but may lead to empty +output. + .TP .B up only list running interfaces. diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index d5673639..e10f541b 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -1242,6 +1242,12 @@ specifies the master device which enslaves devices to show. .I TYPE specifies the type of devices to show. +Note that the type name is not checked against the list of supported types - +instead it is sent as-is to the kernel. Later it is used to filter the returned +interface list by comparing it with the relevant attribute in case the kernel +didn't filter already. Therefore any string is accepted, but may lead to empty +output. + .SS ip link help - display help .PP From 0aae23468ac57924c040ef4588ecd6b6dcb33075 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 22 Jun 2016 12:05:38 +0200 Subject: [PATCH 2/6] Fix MAC address length check I forgot to change the variable in the conditional, too. Fixes: 8fe58d58941f4 ("iplink: Check address length via netlink") Signed-off-by: Phil Sutter --- ip/iplink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip/iplink.c b/ip/iplink.c index 68e5faea..b1f8a379 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -491,7 +491,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, } else if (matches(*argv, "address") == 0) { NEXT_ARG(); addr_len = ll_addr_a2n(abuf, sizeof(abuf), *argv); - if (len < 0) + if (addr_len < 0) return -1; addattr_l(&req->n, sizeof(*req), IFLA_ADDRESS, abuf, addr_len); } else if (matches(*argv, "broadcast") == 0 || From 296cee6fdfaabfbf29a9f6bbf106c83c82c1d838 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Tue, 21 Jun 2016 15:28:26 -0400 Subject: [PATCH 3/6] bridge: vlan: fix a few "fdb" typos in vlan doc Signed-off-by: Vivien Didelot --- bridge/vlan.c | 2 +- man/man8/bridge.8 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bridge/vlan.c b/bridge/vlan.c index 717025ae..a8a2e1d9 100644 --- a/bridge/vlan.c +++ b/bridge/vlan.c @@ -299,6 +299,6 @@ int do_vlan(int argc, char **argv) } else return vlan_show(0, NULL); - fprintf(stderr, "Command \"%s\" is unknown, try \"bridge fdb help\".\n", *argv); + fprintf(stderr, "Command \"%s\" is unknown, try \"bridge vlan help\".\n", *argv); exit(-1); } diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index 08e8a5bf..1818542e 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -551,8 +551,8 @@ device is the bridge device. .BI master the vlan is configured on the software bridge (default). -.SS bridge vlan delete - delete a forwarding database entry -This command removes an existing fdb entry. +.SS bridge vlan delete - delete a vlan filter entry +This command removes an existing vlan filter entry. .PP The arguments are the same as with From 7fab22abd1ff6c8e8d4e5cd3602d7c28a3fa98de Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Tue, 21 Jun 2016 15:28:50 -0400 Subject: [PATCH 4/6] bridge: man: fix "brige" typo Signed-off-by: Vivien Didelot --- man/man8/bridge.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man8/bridge.8 b/man/man8/bridge.8 index 1818542e..ac42118e 100644 --- a/man/man8/bridge.8 +++ b/man/man8/bridge.8 @@ -234,7 +234,7 @@ error. .sp .B 1 -- STP LISTENING state. Only valid if STP is enabled on the brige. In this +- STP LISTENING state. Only valid if STP is enabled on the bridge. In this state the port for list for STP BPDUs and drop all other traffic. .sp From 2a6f9cfa8b31a4adf2ba6a3f9b2c8c69ea8f65b5 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Tue, 21 Jun 2016 16:29:01 -0700 Subject: [PATCH 5/6] man: ip-link: Add vrf type Add description for vrf type to ip-link man page. Signed-off-by: David Ahern --- man/man8/ip-link.8.in | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index e10f541b..375b4d08 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -65,7 +65,8 @@ ip-link \- network device configuration .BR nlmon " |" .BR ipvlan " |" .BR lowpan " |" -.BR geneve " ]" +.BR geneve " |" +.BR vrf " ]" .ti -8 .BR "ip link delete " { @@ -263,6 +264,9 @@ Link types: .sp .BR macsec - Interface for IEEE 802.1AE MAC Security (MACsec) +.sp +.BR vrf +- Interface for L3 VRF domains .in -8 .TP @@ -966,6 +970,20 @@ the following additional arguments are supported: .in -8 +.TP +VRF Type Support +For a link of type +.I VRF +the following additional arguments are supported: + +.BI "ip link add " DEVICE " type vrf table " TABLE + +.in +8 +.sp +.BR table " table id associated with VRF device" + +.in -8 + .SS ip link delete - delete virtual link .TP From 08401220a936cedd439a605c923122825641ff44 Mon Sep 17 00:00:00 2001 From: Jakub Sitnicki Date: Wed, 22 Jun 2016 13:34:13 +0200 Subject: [PATCH 6/6] ip/tcp_metrics: Simplify process_msg a bit On Tue, Jun 21, 2016 at 06:18 PM CEST, Phil Sutter wrote: > By combining the attribute extraction and check for existence, the > additional indentation level in the 'else' clause can be avoided. > > In addition to that, common actions for 'daddr' are combined since the > function returns if neither of the branches are taken. > > Signed-off-by: Phil Sutter > --- > ip/tcp_metrics.c | 45 ++++++++++++++++++--------------------------- > 1 file changed, 18 insertions(+), 27 deletions(-) > > diff --git a/ip/tcp_metrics.c b/ip/tcp_metrics.c > index f82604f458ada..899830c127bcb 100644 > --- a/ip/tcp_metrics.c > +++ b/ip/tcp_metrics.c > @@ -112,47 +112,38 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, > parse_rtattr(attrs, TCP_METRICS_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, > len); > > - a = attrs[TCP_METRICS_ATTR_ADDR_IPV4]; > - if (a) { > + if ((a = attrs[TCP_METRICS_ATTR_ADDR_IPV4])) { Copy the pointer inside the branch? Same gain on indentation while keeping checkpatch happy. I only compile-tested the patch below. Thanks, Jakub --- ip/tcp_metrics.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/ip/tcp_metrics.c b/ip/tcp_metrics.c index f82604f4..ac2613a0 100644 --- a/ip/tcp_metrics.c +++ b/ip/tcp_metrics.c @@ -112,47 +112,44 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, parse_rtattr(attrs, TCP_METRICS_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, len); - a = attrs[TCP_METRICS_ATTR_ADDR_IPV4]; - if (a) { + if (attrs[TCP_METRICS_ATTR_ADDR_IPV4]) { if (f.daddr.family && f.daddr.family != AF_INET) return 0; + a = attrs[TCP_METRICS_ATTR_ADDR_IPV4]; memcpy(&daddr.data, RTA_DATA(a), 4); daddr.bytelen = 4; family = AF_INET; atype = TCP_METRICS_ATTR_ADDR_IPV4; dlen = RTA_PAYLOAD(a); - } else { - a = attrs[TCP_METRICS_ATTR_ADDR_IPV6]; - if (a) { - if (f.daddr.family && f.daddr.family != AF_INET6) - return 0; - memcpy(&daddr.data, RTA_DATA(a), 16); - daddr.bytelen = 16; - family = AF_INET6; - atype = TCP_METRICS_ATTR_ADDR_IPV6; - dlen = RTA_PAYLOAD(a); - } else + } else if (attrs[TCP_METRICS_ATTR_ADDR_IPV6]) { + if (f.daddr.family && f.daddr.family != AF_INET6) return 0; + a = attrs[TCP_METRICS_ATTR_ADDR_IPV6]; + memcpy(&daddr.data, RTA_DATA(a), 16); + daddr.bytelen = 16; + family = AF_INET6; + atype = TCP_METRICS_ATTR_ADDR_IPV6; + dlen = RTA_PAYLOAD(a); + } else { + return 0; } - a = attrs[TCP_METRICS_ATTR_SADDR_IPV4]; - if (a) { + if (attrs[TCP_METRICS_ATTR_SADDR_IPV4]) { if (f.saddr.family && f.saddr.family != AF_INET) return 0; + a = attrs[TCP_METRICS_ATTR_SADDR_IPV4]; memcpy(&saddr.data, RTA_DATA(a), 4); saddr.bytelen = 4; stype = TCP_METRICS_ATTR_SADDR_IPV4; slen = RTA_PAYLOAD(a); - } else { + } else if (attrs[TCP_METRICS_ATTR_SADDR_IPV6]) { + if (f.saddr.family && f.saddr.family != AF_INET6) + return 0; a = attrs[TCP_METRICS_ATTR_SADDR_IPV6]; - if (a) { - if (f.saddr.family && f.saddr.family != AF_INET6) - return 0; - memcpy(&saddr.data, RTA_DATA(a), 16); - saddr.bytelen = 16; - stype = TCP_METRICS_ATTR_SADDR_IPV6; - slen = RTA_PAYLOAD(a); - } + memcpy(&saddr.data, RTA_DATA(a), 16); + saddr.bytelen = 16; + stype = TCP_METRICS_ATTR_SADDR_IPV6; + slen = RTA_PAYLOAD(a); } if (f.daddr.family && f.daddr.bitlen >= 0 &&