aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2019-01-22 11:11:15 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2019-01-22 15:22:05 +0100
commit414be6c1112f8fa5d444f902ca0061f631a46522 (patch)
tree4b44083c79d6f3b52c18117540ad01d7b9ef6788 /networking
parentf50faf84081caa3ce325d2ec69f9dda2520174d9 (diff)
downloadbusybox-414be6c1112f8fa5d444f902ca0061f631a46522.tar.gz
ip link: Fix vlan proto, closes 8261 and 11638
The proto has to be passed in network byte-order. While at it allow for ip link add link eth0 name eth0.2.24 type vlan proto 802.1ad id 24 ip link del link eth0 name eth0.2.24 type vlan proto 802.1ad id 24 The del was lacking a dev_str and thus errored out. Fix by using name/dev counterpart as fallback. The proto identifier 802.1Q was not recognized, just it's lowercase variant, fix that too. function old new delta do_add_or_delete 1275 1376 +101 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/0 up/down: 101/0) Total: 101 bytes Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/libiproute/iplink.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index 883a1f14a..1a1064bdc 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -518,11 +518,11 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size)
id = get_u16(*argv, "id");
addattr_l(n, size, IFLA_VLAN_ID, &id, sizeof(id));
} else if (arg == ARG_protocol) {
- arg = index_in_substrings(protocols, *argv);
+ arg = index_in_substrings(protocols, str_tolower(*argv));
if (arg == PROTO_8021Q)
- proto = ETH_P_8021Q;
+ proto = htons(ETH_P_8021Q);
else if (arg == PROTO_8021AD)
- proto = ETH_P_8021AD;
+ proto = htons(ETH_P_8021AD);
else
bb_error_msg_and_die("unknown VLAN encapsulation protocol '%s'",
*argv);
@@ -673,13 +673,19 @@ static int do_add_or_delete(char **argv, const unsigned rtm)
linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo;
}
+ /* Allow "ip link add dev" and "ip link add name" */
+ if (!name_str)
+ name_str = dev_str;
+ else if (!dev_str)
+ dev_str = name_str;
+ /* else if (!strcmp(name_str, dev_str))
+ name_str = dev_str; */
+
if (rtm != RTM_NEWLINK) {
if (!dev_str)
return 1; /* Need a device to delete */
req.i.ifi_index = xll_name_to_index(dev_str);
} else {
- if (!name_str)
- name_str = dev_str;
if (link_str) {
int idx = xll_name_to_index(link_str);
addattr_l(&req.n, sizeof(req), IFLA_LINK, &idx, 4);